private void HandleMultiInstance() { _mutex = new Mutex(true, @"Global\WinDynamicDesktop", out bool isFirstInstance); GC.KeepAlive(_mutex); if (isFirstInstance) { ipcServer = IpcManager.StartServer(); } else { if (ThemeManager.importPaths.Count > 0) { // TODO Test passing string[] through named pipe IpcManager.SendArgsToServer(ThemeManager.importPaths.ToArray()); } else { MessageDialog.ShowWarning(_("Another instance of WinDynamicDesktop is already running. You can " + "access it by clicking on the icon in the system tray."), _("Error")); } Environment.Exit(0); } }
public WindowsPipeServer(string channel) { server = new NamedPipeWrapper.NamedPipeServer <BaseMessage>(channel, GetSecurityForChannel()); server.ClientConnected += (conn) => ClientConnected?.Invoke(this); server.ClientDisconnected += (conn) => ClientDisconnected?.Invoke(this); server.ClientMessage += (conn, msg) => ClientMessage?.Invoke(this, msg); server.Error += (ex) => Error?.Invoke(ex); }