How to apply InterLocked.Exchange for Enum Types in C#?

前端 未结 5 922
难免孤独
难免孤独 2021-02-12 22:39
public enum MyEnum{Value1, Value2}  
class MyClass 
{ 
    private MyEnum _field;   
    public MyEnum Field  // added for convenience
    {
        get { return _field;         


        
5条回答
  •  南方客
    南方客 (楼主)
    2021-02-12 22:59

    Why not simply synchonrize the threading?

    protected static object _lockObj = new object();
    
    set
    {
        lock(_lockObj)
        {
             _field = value;
        }
    }
    

提交回复
热议问题