diff --git a/Common.csproj b/Common.csproj index 5ea00e1..d693b1e 100644 --- a/Common.csproj +++ b/Common.csproj @@ -145,6 +145,7 @@ + diff --git a/IO/ProcessAsync.cs b/IO/ProcessAsync.cs new file mode 100644 index 0000000..583aa0c --- /dev/null +++ b/IO/ProcessAsync.cs @@ -0,0 +1,33 @@ +using System.Diagnostics; +using System.Threading.Tasks; + +namespace Common.IO +{ + public class ProcessAsync + { + public static Task RunProcessAsync(string fileName, string arguments) + { + var taskCompletionSource = new TaskCompletionSource(); + + var process = new Process + { + StartInfo = + { + FileName = fileName, + Arguments = arguments + }, + EnableRaisingEvents = true + }; + + process.Exited += (sender, args) => + { + taskCompletionSource.SetResult(true); + process.Dispose(); + }; + + process.Start(); + + return taskCompletionSource.Task; + } + } +}