Exemple #1
0
 public void TestBusyLockObject()
 {
     BusyBO busy = new BusyBO();
       busy.MarkBusy(true);
       using (BusyLocker bl = new BusyLocker(busy, TimeSpan.FromSeconds(1)))
       {
     System.ComponentModel.BackgroundWorker worker = new System.ComponentModel.BackgroundWorker();
     worker.DoWork += (o, e) => busy.MarkBusy(false);
     worker.RunWorkerAsync();
       }
       Assert.IsFalse(busy.IsBusy);
 }
Exemple #2
0
        /// <summary>
        /// Wait until the specified object is not busy
        /// (IsBusy is false).
        /// </summary>
        /// <param name="obj">Target object.</param>
        /// <param name="timeout">Timeout value.</param>
        public static void WaitOne(INotifyBusy obj, TimeSpan timeout)
        {
            BusyLocker locker = new BusyLocker(obj, timeout);

            locker.WaitOne();
        }
Exemple #3
0
        /// <summary>
        /// Wait until the specified object is not busy
        /// (IsBusy is false).
        /// </summary>
        /// <param name="obj">Target object.</param>
        public static void WaitOne(INotifyBusy obj)
        {
            BusyLocker locker = new BusyLocker(obj, TimeSpan.FromMilliseconds(Timeout.Infinite));

            locker.WaitOne();
        }
Exemple #4
0
 /// <summary>
 /// Wait until the specified object is not busy 
 /// (IsBusy is false).
 /// </summary>
 /// <param name="obj">Target object.</param>
 /// <param name="timeout">Timeout value.</param>
 public static void WaitOne(INotifyBusy obj, TimeSpan timeout)
 {
   BusyLocker locker = new BusyLocker(obj, timeout);
   locker.WaitOne();
 }
Exemple #5
0
 /// <summary>
 /// Wait until the specified object is not busy 
 /// (IsBusy is false).
 /// </summary>
 /// <param name="obj">Target object.</param>
 public static void WaitOne(INotifyBusy obj)
 {
   BusyLocker locker = new BusyLocker(obj, TimeSpan.FromMilliseconds(Timeout.Infinite));
   locker.WaitOne();
 }