Threading with Mutex : Mutex : Thread C# Examples


C# Examples » Thread » Mutex »

 

Threading with Mutex









    
using  System;
using  System.Collections;
using  System.Threading;

class  MainClass  
{
    public  static  ArrayList  MyList  =  new  ArrayList();

    private  static  Mutex  MyMutex  =  new  Mutex(false,  "MyMutex");

    static  void  Main(string[]  args)
    {
            Thread  ThreadOne  =  new  Thread(new  ThreadStart(MutexExample));
        ThreadOne.Start();
    }
    protected  static  void  MutexExample()
    {
        MyMutex.WaitOne();
        MyList.Add("  a  value");
        MyMutex.ReleaseMutex();
    }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Thread
» Mutex