public async Task SingleProcess_WaitAfterExited(bool addHandlerBeforeStart)
{
Process p = CreateProcessLong();
p.EnableRaisingEvents = true;
var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
if (addHandlerBeforeStart)
{
p.Exited += delegate { tcs.SetResult(true); };
}
p.Start();
if (!addHandlerBeforeStart)
{
p.Exited += delegate { tcs.SetResult(true); };
}
p.Kill();
Assert.True(await tcs.Task);
Assert.True(p.WaitForExit(0));
}