示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }