Monitor : Monitor : Thread C# Examples


C# Examples » Thread » Monitor »

 

Monitor









    
using  System;
using  System.Threading;

class  MainClass  
{
    [STAThread]
    static  void  Main(string[]  args)
    {
        object  t  =  new  object();
        int  r  =  0;
        try
        {
            if  (  Monitor.TryEnter(  t,  250  )  )
            {
                r++;
            }
        }
        finally
        {
            try
            {
                Monitor.Exit(  t  );
            }
            catch(  SynchronizationLockException  sle  )
            {
                Console.WriteLine(sle);
            }
        }
    }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Thread
» Monitor