[Process] Fix NonChildProcessWaitForExit Exited callback (#4409)
authorLudovic Henry <ludovic@xamarin.com>
Tue, 21 Feb 2017 23:42:42 +0000 (18:42 -0500)
committerGitHub <noreply@github.com>
Tue, 21 Feb 2017 23:42:42 +0000 (18:42 -0500)
mcs/class/System/Test/System.Diagnostics/ProcessTest.cs

index 5db7246a4bd45ba8a60c47dc69427edb2d94f7c6..cb3827785af4dab4ced082075e03b608d27e1861 100644 (file)
@@ -1139,13 +1139,15 @@ namespace MonoTests.System.Diagnostics
                                Assert.Ignore ("accessing parent pid, only available on unix");
 
                        using (Process process = Process.GetProcessById (getppid ()))
+                       using (ManualResetEvent mre = new ManualResetEvent (false))
                        {
                                Assert.IsFalse (process.WaitForExit (10), "#1");
                                Assert.IsFalse (process.HasExited, "#2");
                                Assert.Throws<InvalidOperationException>(delegate { int exitCode = process.ExitCode; }, "#3");
 
-                               process.Exited += (s, e) => Assert.Fail ("#4");
+                               process.Exited += (s, e) => mre.Set ();
                                process.EnableRaisingEvents = true;
+                               Assert.IsFalse (mre.WaitOne (100), "#4");
 
                                Assert.IsFalse (process.WaitForExit (10), "#5");
                                Assert.IsFalse (process.HasExited, "#6");