Example #1
0
 /// <summary>
 /// Start the VM's where the extradata key is set
 /// </summary>
 private void startvms()
 {
     if (machines.Length == 0)
     {
         return;
     }
     foreach (VirtualBox.IMachine m in machines)
     {
         string xtrakeys = m.GetExtraData(this.extradatakey.ToString());
         if (xtrakeys.ToLower() == "yes")
         {
             if (m.State == VirtualBox.MachineState.MachineState_PoweredOff || m.State == VirtualBox.MachineState.MachineState_Saved)
             {
                 this.EventLog.WriteEntry(String.Format("Starting VM {0} ({1})", m.Name, m.Id));
                 VirtualBox.Session session = new VirtualBox.Session();
                 try {
                     VirtualBox.IProgress progress = m.Parent.OpenRemoteSession(session, m.Id, "vrdp", "");
                     progress.WaitForCompletion(-1);
                 } catch (Exception e) {
                     this.EventLog.WriteEntry(String.Format("Error starting VM {0} ({1})\r\n\r\n{2}", m.Name, m.Id, e.ToString()), EventLogEntryType.Error);
                 }
             }
         }
     }
 }
Example #2
0
 public override void Wait(int timeout)
 {
     _progress.WaitForCompletion(timeout);
     if (_progress.Completed != 1)
     {
         WaitTimedOut = true;
     }
     throwPossibleException();
 }