From a58aeafe1d3cc93dbb84e4b852dfda90cf466e8c Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Tue, 24 Jun 2014 14:19:54 +0200 Subject: [PATCH] [corlib] Fix racy test --- .../System.Runtime.CompilerServices/TaskAwaiterTest.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mcs/class/corlib/Test/System.Runtime.CompilerServices/TaskAwaiterTest.cs b/mcs/class/corlib/Test/System.Runtime.CompilerServices/TaskAwaiterTest.cs index a403d5287e2..b8fd573a366 100644 --- a/mcs/class/corlib/Test/System.Runtime.CompilerServices/TaskAwaiterTest.cs +++ b/mcs/class/corlib/Test/System.Runtime.CompilerServices/TaskAwaiterTest.cs @@ -102,6 +102,7 @@ namespace MonoTests.System.Runtime.CompilerServices string progress; SynchronizationContext sc; + ManualResetEvent mre; [SetUp] public void Setup () @@ -270,6 +271,7 @@ namespace MonoTests.System.Runtime.CompilerServices [Test] public void CompletionOnDifferentCustomSynchronizationContext () { + mre = new ManualResetEvent (false); progress = ""; var syncContext = new SingleThreadSynchronizationContext (); SynchronizationContext.SetSynchronizationContext (syncContext); @@ -293,14 +295,18 @@ namespace MonoTests.System.Runtime.CompilerServices { await Wait2 (ctx); - progress += "2"; + if (mre.WaitOne (5000)) + progress += "2"; } async Task Wait2 (SynchronizationContext ctx) { await Task.Delay (10); // Force block suspend/return - ctx.Post (l => progress += "3", null); + ctx.Post (l => { + progress += "3"; + mre.Set (); + }, null); progress += "1"; -- 2.25.1