Skip to content

Commit

Permalink
Fix TestExited_SynchronizingObject test (dotnet#37639)
Browse files Browse the repository at this point in the history
Fix race condition.
  • Loading branch information
stephentoub authored Jun 9, 2020
1 parent 3b5a51a commit 8d3e718
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public void TestEnableRaiseEvents(bool? enable)
[InlineData(true)]
public void TestExited_SynchronizingObject(bool invokeRequired)
{
bool exitedInvoked = false;
var mres = new ManualResetEventSlim();
Task beginInvokeTask = null;

Process p = CreateProcessLong();
Expand All @@ -154,20 +154,20 @@ public void TestExited_SynchronizingObject(bool invokeRequired)
}
};
p.EnableRaisingEvents = true;
p.Exited += delegate { exitedInvoked = true; };
p.Exited += delegate { mres.Set(); };
StartSleepKillWait(p);

Assert.True(mres.Wait(WaitInMS));

if (invokeRequired)
{
Assert.NotNull(beginInvokeTask);
beginInvokeTask.Wait();
Assert.True(beginInvokeTask.Wait(WaitInMS));
}
else
{
Assert.Null(beginInvokeTask);
}

Assert.True(exitedInvoked);
}

[Fact]
Expand Down

0 comments on commit 8d3e718

Please sign in to comment.