public static void RunPipeServer(Application app, string appPipName) { while (true) { try { NamedPipeServerStream pipeServer = new NamedPipeServerStream(appPipName, PipeDirection.InOut, 2); pipeServer.WaitForConnection(); StreamReader sr = new StreamReader(pipeServer); string recData = sr.ReadLine(); if (recData == "ShowMainWindow") { Global.Execute(new ShowMainWindowCommand()); } else if (recData == "CloseMainWindow") { Execute.OnUIThread(() => { app.MainWindow.Close(); }); } sr.Close(); } catch (Exception ex) { Global.Logger.Error(ex.Message, ex); } } }