LockForWriting() public method

public LockForWriting ( ) : void
return void
Esempio n. 1
0
 static void Main(string[] args)
 {
     ThreadPool.QueueUserWorkItem(_ =>
     {
         MySmartReaderWriterLock rwl1 = new MySmartReaderWriterLock(10);
         Console.WriteLine("Work item 1 locking for writing...");
         rwl1.LockForWriting();
         Console.WriteLine("Work item 1 locked for writing");
         rwl1.UnlockForWriting();
         Console.WriteLine("Work item 1 done");
     });
     ThreadPool.QueueUserWorkItem(_ =>
     {
         MySmartReaderWriterLock rwl2 = new MySmartReaderWriterLock(10);
         Console.WriteLine("Work item 2 locking for writing...");
         rwl2.LockForWriting();
         Console.WriteLine("Work item 2 locked for writing");
         rwl2.UnlockForWriting();
         Console.WriteLine("Work item 2 done");
     });
     Console.ReadLine();
 }
Esempio n. 2
0
 static void Main(string[] args)
 {
     ThreadPool.QueueUserWorkItem(_ =>
     {
         MySmartReaderWriterLock rwl1 = new MySmartReaderWriterLock(10);
         Console.WriteLine("Work item 1 locking for writing...");
         rwl1.LockForWriting();
         Console.WriteLine("Work item 1 locked for writing");
         rwl1.UnlockForWriting();
         Console.WriteLine("Work item 1 done");
     });
     ThreadPool.QueueUserWorkItem(_ =>
     {
         MySmartReaderWriterLock rwl2 = new MySmartReaderWriterLock(10);
         Console.WriteLine("Work item 2 locking for writing...");
         rwl2.LockForWriting();
         Console.WriteLine("Work item 2 locked for writing");
         rwl2.UnlockForWriting();
         Console.WriteLine("Work item 2 done");
     });
     Console.ReadLine();
 }