コード例 #1
0
ファイル: Program.cs プロジェクト: knightfall/writeasync
        private static async Task StartAndWaitForProcessAsync(CancellationToken token)
        {
            int exitCode;
            DateTime exitTime;

            using (Process process = await Task.Factory.StartNew(() => Process.Start("notepad.exe")))
            using (ProcessExitWatcher watcher = new ProcessExitWatcher(new ProcessExit(process)))
            {
                Console.WriteLine("Waiting for Notepad to exit...");
                await watcher.WaitForExitAsync(token);
                exitCode = watcher.Status.ExitCode;
                exitTime = watcher.Status.ExitTime;
            }

            Console.WriteLine("Done, exited with code {0} at {1}.", exitCode, exitTime);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: sujit1779/writeasync
        private static async Task StartAndWaitForProcessAsync(CancellationToken token)
        {
            int      exitCode;
            DateTime exitTime;

            using (Process process = await Task.Factory.StartNew(() => Process.Start("notepad.exe")))
                using (ProcessExitWatcher watcher = new ProcessExitWatcher(new ProcessExit(process)))
                {
                    Console.WriteLine("Waiting for Notepad to exit...");
                    await watcher.WaitForExitAsync(token);

                    exitCode = watcher.Status.ExitCode;
                    exitTime = watcher.Status.ExitTime;
                }

            Console.WriteLine("Done, exited with code {0} at {1}.", exitCode, exitTime);
        }