public void Start() { if (server == null) { server = new PipeServer(); server.OnMessage.Subscribe(OnMessageArrived); server.Start(); } }
// Handle Exited event and display process information. private void myProcess_Exited(object sender, System.EventArgs e) { Console.WriteLine( $"Exit time : {pipeClient.ExitTime}\n" + $"Exit code : {pipeClient.ExitCode}\n" + $"Elapsed time : {Math.Round((pipeClient.ExitTime - pipeClient.StartTime).TotalMilliseconds)}"); eventHandled.TrySetResult(true); Console.WriteLine("Deberia abrir otro window"); PipeServer pipeServer = new PipeServer(); pipeServer.StartProcess(); }
static void Main(string[] args) { System.Threading.CancellationTokenSource cancellationTokenSource = new System.Threading.CancellationTokenSource(); Task t = new Task(() => { PipeServer pipeServer = new PipeServer(); pipeServer.start(cancellationTokenSource.Token); pipeServer = null; }); t.Start(); Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e) { e.Cancel = true; Program.keepRunning = false; }; while (Program.keepRunning) { // Do your work in here, in small chunks. // If you literally just want to wait until ctrl-c, // not doing anything, see the answer using set-reset events. } }
static void Main() { PipeServer pipeServer = new PipeServer(); pipeServer.StartProcess(); }