10using System.Threading;
22 public static class BusyLock
31 BusyLocker locker =
new BusyLocker(obj,
TimeSpan.FromMilliseconds(Timeout.Infinite));
41 public static void WaitOne(
INotifyBusy obj, TimeSpan timeout)
43 BusyLocker locker =
new BusyLocker(obj, timeout);
54 private ManualResetEvent _event =
new ManualResetEvent(
false);
56 private TimeSpan _timeout;
84 _event.WaitOne(_timeout);
86 _event.WaitOne(_timeout,
false);
Event arguments for the BusyChanged event.
Implementation of a lock that waits while a target object is busy.
void WaitOne()
Waits for the target object to become not busy.
BusyLocker(INotifyBusy target, TimeSpan timeout)
Creates an instance of the object.
void Dispose()
Disposes the object.
Interface defining an object that notifies when it is busy executing an asynchronous operation.
BusyChangedEventHandler BusyChanged
Event raised when the object's busy status changes.
bool IsBusy
Gets a value indicating whether the object, or any of the object's child objects, are busy running an...
delegate void BusyChangedEventHandler(object sender, BusyChangedEventArgs e)
Delegate for handling the BusyChanged event.
@ TimeSpan
TimeSpan - time span