Example #1
0
 public bool SpawnVM(StartupParams startup, ISpawnHandler spawnHandler)
 {
     try
     {
         _spawnHandler       = spawnHandler;
         _spawnCorrelationID = Guid.NewGuid();
         Logger.Write(string.Format("Sending VMSpawnMessage with {0} and {1}", _spawnCorrelationID, startup.WatchToken));
         var thread = new Thread(send);
         thread.Start(new VMSpawnMeessage(_spawnCorrelationID, 0, startup.WatchToken));
         var timeout = DateTime.Now.AddSeconds(1);
         while (DateTime.Now < timeout)
         {
             Thread.Sleep(10);
             if (_host == null)
             {
                 continue;
             }
             if (thread.ThreadState == ThreadState.Stopped)
             {
                 break;
             }
         }
         thread.Abort();
         if (_host == null)
         {
             return(false);
         }
         return(_host.IsConnected);
     }
     catch (Exception ex)
     {
         Logger.Write(ex);
         return(false);
     }
 }
Example #2
0
 public bool SpawnVM(StartupParams startup, ISpawnHandler spawnHandler)
 {
     try
     {
         _spawnHandler = spawnHandler;
         _spawnCorrelationID = Guid.NewGuid();
         Logger.Write(string.Format("Sending VMSpawnMessage with {0} and {1}", _spawnCorrelationID, startup.WatchToken));
         var thread = new Thread(send);
         thread.Start(new VMSpawnMeessage(_spawnCorrelationID, 0, startup.WatchToken));
         var timeout = DateTime.Now.AddSeconds(1);
         while (DateTime.Now < timeout)
         {
             Thread.Sleep(10);
             if (_host == null)
                 continue;
             if (thread.ThreadState == ThreadState.Stopped)
                 break;
         }
         thread.Abort();
         if (_host == null)
             return false;
         return _host.IsConnected;
     }
     catch (Exception ex)
     {
         Logger.Write(ex);
         return false;
     }
 }