/// <summary> /// Connects this instance. /// </summary> /// <remarks>Documented by Dev02, 2009-06-26</remarks> /// <exception cref="MLCouldNotBeStartedException">Occurs when MemoryLifter did not start or did not react to connection attempts.</exception> /// <exception cref="MLNotReadyException">Occurs when MemoryLifter is not ready for being remote controlled.</exception> private void Connect() { Debug.WriteLine("Connecting to MemoryLifter..."); MLifter.Program.GetIPCData(out UniqueChannelName, out UniqueChannelPortName, out ClientURL, out ServiceURL); loader = (GlobalDictionaryLoader)RemotingServices.Connect(typeof(GlobalDictionaryLoader), ClientURL); int tries; try { tries = 20; while (!loader.IsMLReady()) { Thread.Sleep(50); if (tries-- < 0) throw new MLNotReadyException(); } } catch (RemotingException) { StartML(); Thread.Sleep(200); try { tries = 100; while (!loader.IsMLReady()) { Thread.Sleep(50); if (tries-- < 0) throw new MLNotReadyException(); } } catch (RemotingException) { throw; } } return; }