C # considerate place bit by bit - lock

Original link: http://www.cnblogs.com/jamesleng/archive/2011/10/20/2217607.html

I am talking about how considerate C # programmer, rather than .NET Framework.

 

This is the use of the C # minor effort Monitor:    
    MyClass obj;
    // s Some code to the initialize obj;

    Lock (obj)
    {
       obj.DoSomething ();
    }

The above code is equivalent to the following, how, C # considerate not?
   Obj MyClass;
   // s Some code to the initialize obj;

 the Monitor.Enter (obj);
   the try
   {
      obj.DoSomething ();
   }
  the finally
  {
     . Monitor the Exit (obj);
  }

 

(按:code source from <<Programming .NET Components>> 2nd.Edition Juval Lowy)

Reproduced in: https: //www.cnblogs.com/jamesleng/archive/2011/10/20/2217607.html

Guess you like

Origin blog.csdn.net/weixin_30793643/article/details/94786447
Bit
BIT