Skip to content

Instantly share code, notes, and snippets.

@tanaka-takayoshi
Created June 27, 2013 13:24
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 tanaka-takayoshi/5876358 to your computer and use it in GitHub Desktop.
Save tanaka-takayoshi/5876358 to your computer and use it in GitHub Desktop.
static Task RunProcess(ProcessStartInfo psi)
{
var tcs = new TaskCompletionSource<bool>();
var process = new Process
{
StartInfo = psi,
EnableRaisingEvents = true
};
process.ErrorDataReceived += (s, e) => tcs.SetException(new Exception("err"));
process.Exited += (sender, args) => tcs.SetResult(true);
process.Start();
return tcs.Task;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment