private void connectToStandAloneInstances()
 {
     var handleManager = new VMConnectHandle();
     while (true)
     {
         var handles = handleManager.GetAll().Where(x => !_nodes.Exists(y => y.IP.Equals(x.IP) && y.Port.Equals(x.Port))).ToList();
         foreach (var handle in handles)
         {
             var node = new DiagnosticNode(
                 handle.IP,
                 handle.Port,
                 handle.ProcessID,
                 handle.Token,
                 (m) => node_MessageReceived(handle.Token, new MessageReceivedEventArgs(m)));
             if (node.IsConnected)
             {
                 addNode(node);
             }
             else
             {
                 try
                 {
                     File.Delete(handle.File);
                 }
                 catch
                 {
                 }
             }
         }
         Thread.Sleep(5000);
     }
 }
 private void ConnectToExistingVm()
 {
     VMHandle handle = null;
     while(handle == null)
     {
         handle = new VMConnectHandle().GetCurrent();
     }
     client = new NetClient(new DebugClientFeedbackProvider());
     client.MessageReceived += ClientMessageReceived;
     client.Connect(handle.IP, handle.Port);
 }
 /// <summary>
 /// Get engines from token. Token can be solution file or watch folder
 /// </summary>
 /// <param name="token">The engine watch token to look for. The token is either the solution file or the watch folder</param>
 /// <param name="caseInsensitive">Wether to match the token ignoring case</param>
 /// <returns>Engine</returns>
 public IEngine GetEngine(string token, bool caseInsensitive)
 {
     VMHandle activeHandle = null;
     var connect = new VMConnectHandle();
     var handles = connect.GetFromToken(token, caseInsensitive);
     var toDelete = new List<string>();
     foreach (var handle in handles)
     {
         if (canConnect(handle))
         {
             activeHandle = handle;
             break;
         }
         toDelete.Add(handle.File);
     }
     toDelete.ForEach(x => { try { File.Delete(x); } catch { } });
     if (activeHandle == null)
         return null;
     return new Engine(activeHandle);
 }