I am new to C#. In Java, I can make read/write of a Java class member by having 'synchronized' keyword in the setter/getter method.
Can you please tell me what is the right way to do the same in C#? In C# there is no synchronized keyword. Should I use '[MethodImpl(MethodImplOptions.Synchronized)] annotation' mentioned in C# version of java's synchronized keyword??
Or use Monitor.Enter (and subsequently Monitor.Exit)?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…