예제 #1
0
        public void TestTimeout()
        {
            BusyBO busy = new BusyBO();

            busy.MarkBusy(true);
            BusyLock.WaitOne(busy, TimeSpan.FromMilliseconds(10));
            Assert.IsTrue(busy.IsBusy);
        }
예제 #2
0
        public void SimpleLock()
        {
            BusyBO busy = new BusyBO();

            busy.MarkBusy(true);
            System.ComponentModel.BackgroundWorker worker = new System.ComponentModel.BackgroundWorker();
            worker.DoWork += (o, e) =>
            {
                System.Threading.Thread.Sleep(10);
                busy.MarkBusy(false);
            };
            worker.RunWorkerAsync();

            BusyLock.WaitOne(busy);
            Assert.IsFalse(busy.IsBusy);
        }