Index: test/Common/DelftTools.Utils.Tests/Threading/ThreadsafeBindingListTest.cs =================================================================== diff -u -r8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9 -r5fc71a385897af92ccb092f2f969b5709afab85a --- test/Common/DelftTools.Utils.Tests/Threading/ThreadsafeBindingListTest.cs (.../ThreadsafeBindingListTest.cs) (revision 8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9) +++ test/Common/DelftTools.Utils.Tests/Threading/ThreadsafeBindingListTest.cs (.../ThreadsafeBindingListTest.cs) (revision 5fc71a385897af92ccb092f2f969b5709afab85a) @@ -7,18 +7,6 @@ [TestFixture] public class ThreadsafeBindingListTest { - //a synchronization context provides synchronized execution. - //this one only checks the call to send was made. - public class MockContext : SynchronizationContext - { - public int SendWasCalled { get; set; } - //just run the thing. - public override void Send(SendOrPostCallback d, object state) - { - SendWasCalled++; - } - } - [Test] public void ListChangedEventIsAlwaysOnTheThreadThatCreatedTheList() { @@ -33,26 +21,35 @@ //create a new thread adding something to the list //use an anonymous lambda expression delegate :) - var addFiveThread = new Thread(() => - { - list.Add(5); - }); + var addFiveThread = new Thread(() => { list.Add(5); }); //action! run the thread adding 5 addFiveThread.Start(); //wait for the other thread to finish while (addFiveThread.IsAlive) + { Thread.Sleep(10); + } //assert the list used the context. Assert.AreEqual(1, context.SendWasCalled, "The list did not use the send method the current context!"); - } finally { //always reset the synchronizationcontext SynchronizationContext.SetSynchronizationContext(null); } - } + + //a synchronization context provides synchronized execution. + //this one only checks the call to send was made. + public class MockContext : SynchronizationContext + { + public int SendWasCalled { get; set; } + //just run the thing. + public override void Send(SendOrPostCallback d, object state) + { + SendWasCalled++; + } + } } -} +} \ No newline at end of file