9using System.Collections.Generic;
15using System.ComponentModel;
19using TestClass = NUnit.Framework.TestFixtureAttribute;
20using TestInitialize = NUnit.Framework.SetUpAttribute;
21using TestCleanup = NUnit.Framework.TearDownAttribute;
22using TestMethod = NUnit.Framework.TestAttribute;
23using TestSetup = NUnit.Framework.SetUpAttribute;
25using Microsoft.VisualStudio.TestTools.UnitTesting;
42 public bool IsSelfBusy
47 public void MarkBusy(
bool busy)
50 if (BusyChanged !=
null)
56 public event EventHandler<ErrorEventArgs> UnhandledAsyncException;
58 protected virtual void OnUnhandledAsyncException()
60 if (UnhandledAsyncException !=
null)
68 BusyBO busy =
new BusyBO();
70 System.ComponentModel.BackgroundWorker worker =
new System.ComponentModel.BackgroundWorker();
71 worker.DoWork += (o, e) =>
73 System.Threading.Thread.Sleep(10);
76 worker.RunWorkerAsync();
78 BusyLock.WaitOne(busy);
79 Assert.IsFalse(busy.IsBusy);
85 BusyBO busy =
new BusyBO();
87 BusyLock.WaitOne(busy, TimeSpan.FromMilliseconds(10));
88 Assert.IsTrue(busy.IsBusy);
94 BusyBO busy =
new BusyBO();
98 System.ComponentModel.BackgroundWorker worker =
new System.ComponentModel.BackgroundWorker();
99 worker.DoWork += (o, e) => busy.MarkBusy(
false);
100 worker.RunWorkerAsync();
102 Assert.IsFalse(busy.IsBusy);
Event arguments for the BusyChanged event.
Event arguments for an unhandled async exception.
void TestBusyLockObject()
Implementation of a lock that waits while a target object is busy.
Interface defining an object that notifies when it is busy executing an asynchronous operation.
delegate void BusyChangedEventHandler(object sender, BusyChangedEventArgs e)
Delegate for handling the BusyChanged event.