private static void WaitForExitMessage(int seconds, string pipeName) { using (var pipeServer = new PipeServer(pipeName)) { var messageHandler = new WaitHandler(pipeServer, WaitMessage); var start = DateTime.UtcNow; do { Thread.Sleep(5); if (messageHandler.Received) break; } while (DateTime.UtcNow.Subtract(start).Duration().TotalSeconds < seconds); } }
void PipedMessageReceivedHandler(object sender, PipeServer.MessageReceivedEventArgs e) { try { var message = e.Message; if (string.IsNullOrWhiteSpace(message)) return; if (message.Equals(LaunchEngineCommand.WaitMessage, StringComparison.InvariantCulture)) message = "Initializing"; if (message.StartsWith(ErrorPrefix, StringComparison.InvariantCulture)) { SetError(message); return; } Model.Dispatcher.Invoke(new Action(()=>Subtitle=message)); } catch (Exception ex) { Logger.Error(ex); } }
public ExternalProgressPageModel(PagedViewModel model, string pipeName) : base(model) { _pipe = new PipeServer(pipeName); _pipe.MessageReceived += PipedMessageReceivedHandler; }