private bool WaitForOtherInstance() { Timing t = Timing.StartNew(); while (t.Elapsed < TimeSpan.FromSeconds(20)) { try { string id = MainWindowIpcService.GetId(workingFolder); using (IpcRemotingService ipcRemotingService = new IpcRemotingService()) { if (ipcRemotingService.TryCreateServer(id)) { Log.Debug("Other instance has closed"); return(true); } } } catch (Exception e) { Log.Exception(e, "Failed to check if other instance is running"); } Thread.Sleep(100); } Log.Error("Failed to wait for other instance"); return(false); }
private bool IsActivatedOtherInstance() { try { string id = MainWindowIpcService.GetId(workingFolder); using (IpcRemotingService ipcRemotingService = new IpcRemotingService()) { if (!ipcRemotingService.TryCreateServer(id)) { // Another GitMind instance for that working folder is already running, activate that. Log.Debug("Try activate other instance ..."); var args = Environment.GetCommandLineArgs(); ipcRemotingService.CallService <MainWindowIpcService>(id, service => service.Activate(args)); Track.Event("ActivatedOtherInstance"); return(true); } else { Log.Debug("Continue with this instance..."); } } } catch (Exception e) { Log.Exception(e, "Failed to activate other instance"); } return(false); }
private void StartIpcServerSide() { // Start IPC server side, which can receive requests from a tmp GitMind process started by // git, when git requires credentials via the GIT_ASKPASS environment vartiable serverSideIpcService = new IpcRemotingService(); serverSideIpcService.TryCreateServer(SessionId); serverSideIpcService.PublishService(new CredentialIpcService(this)); }
public void Test() { string id = Guid.NewGuid().ToString(); using (IpcRemotingService ipcServerService = new IpcRemotingService()) { Assert.IsTrue(ipcServerService.TryCreateServer(id)); ipcServerService.PublishService(new ServerSide()); using (IpcRemotingService ipcClientService = new IpcRemotingService()) { string request = "Some request text"; string response = ipcClientService.CallService <ServerSide, string>( id, service => service.DoubleText(request)); Assert.AreEqual(request + request, response); } } }
public bool IsActivatedOtherInstance(string workingFolder) { try { string id = MainWindowIpcService.GetId(workingFolder); using (IpcRemotingService ipcRemotingService = new IpcRemotingService()) { if (!ipcRemotingService.TryCreateServer(id)) { // Another GitMind instance for that working folder is already running, activate that. var args = Environment.GetCommandLineArgs(); ipcRemotingService.CallService <MainWindowIpcService>(id, service => service.Activate(args)); return(true); } } } catch (Exception e) { Log.Warn($"Failed to activate other instance {e}"); } return(false); }