public virtual void TestUpdateOnBackgroundThreads() { ThreadSafeProgressMonitorTest.MockProgressMonitor mock = new ThreadSafeProgressMonitorTest.MockProgressMonitor (); ThreadSafeProgressMonitor pm = new ThreadSafeProgressMonitor(mock); pm.StartWorker(); CountDownLatch doUpdate = new CountDownLatch(1); CountDownLatch didUpdate = new CountDownLatch(1); CountDownLatch doEndWorker = new CountDownLatch(1); Sharpen.Thread bg = new _Thread_128(pm, doUpdate, didUpdate, doEndWorker); bg.Start(); pm.PollForUpdates(); NUnit.Framework.Assert.AreEqual(0, mock.value); doUpdate.CountDown(); Await(didUpdate); pm.PollForUpdates(); NUnit.Framework.Assert.AreEqual(2, mock.value); doEndWorker.CountDown(); pm.WaitForCompletion(); NUnit.Framework.Assert.AreEqual(3, mock.value); }
public virtual void TestUpdateOnBackgroundThreads() { ThreadSafeProgressMonitorTest.MockProgressMonitor mock = new ThreadSafeProgressMonitorTest.MockProgressMonitor (); ThreadSafeProgressMonitor pm = new ThreadSafeProgressMonitor(mock); pm.StartWorker(); CountDownLatch doUpdate = new CountDownLatch(1); CountDownLatch didUpdate = new CountDownLatch(1); CountDownLatch doEndWorker = new CountDownLatch(1); Sharpen.Thread bg = new _Thread_128(pm, doUpdate, didUpdate, doEndWorker); bg.Start(); pm.PollForUpdates(); NUnit.Framework.Assert.AreEqual(0, mock.value); doUpdate.CountDown(); Await(didUpdate); pm.PollForUpdates(); NUnit.Framework.Assert.AreEqual(2, mock.value); doEndWorker.CountDown(); pm.WaitForCompletion(); NUnit.Framework.Assert.AreEqual(3, mock.value); }