Skip to content

Instantly share code, notes, and snippets.

@vladima
Last active September 1, 2017 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vladima/d00a609ea473b37dcda07812cc30563c to your computer and use it in GitHub Desktop.
Save vladima/d00a609ea473b37dcda07812cc30563c to your computer and use it in GitHub Desktop.
var process = ...
var timeout = ...
var tcs = new TaskCompletionSource<object>();
process.Exited += delegate {
tcs.SetResult(null);
};
if (await Task.WhenAny(tcs.Task, Task.Delay(timeout)) != tcs.Task)
{
process.Kill();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment