Example #1
0
        public void AttemptReleaseInDifferentThreads()
        {
            Semaphore            s       = new Semaphore(0);
            AttemptReleaseWorker worker1 = new AttemptReleaseWorker(s);
            Thread thread1 = new Thread(new ThreadStart(worker1.DoWork));

            thread1.Start();
            //TODO investigate...
            //Assert.IsTrue(s.Attempt(SHORT_DELAY_MS));
            s.Attempt(SHORT_DELAY_MS);
            s.Release();
            //Assert.IsTrue(s.Attempt(SHORT_DELAY_MS));
            s.Attempt(SHORT_DELAY_MS);
            s.Release();
            s.Release();
            thread1.Join();
        }
Example #2
0
 public void AttemptReleaseInDifferentThreads()
 {
     Semaphore s = new Semaphore(0); 
     AttemptReleaseWorker worker1 = new AttemptReleaseWorker(s);
     Thread thread1 = new Thread(new ThreadStart(worker1.DoWork));
     
     thread1.Start();
     //TODO investigate...
     //Assert.IsTrue(s.Attempt(SHORT_DELAY_MS));
     s.Attempt(SHORT_DELAY_MS);
     s.Release();
     //Assert.IsTrue(s.Attempt(SHORT_DELAY_MS));
     s.Attempt(SHORT_DELAY_MS);
     s.Release();
     s.Release();
     thread1.Join();
 }