[VMware Launcher 2.0.9.7]
- Enhancement: #4 Verify Windows services have properly terminated upon shutdown. - Moved instanciation of ServiceControl class from Startup.xaml.cs to StatusWindow.xaml.cs.
This commit is contained in:
@@ -16,6 +16,9 @@ namespace VMwareLauncher
|
||||
BackgroundWorker runProcess = new BackgroundWorker();
|
||||
BackgroundWorker loadServices = new BackgroundWorker();
|
||||
BackgroundWorker stopServices = new BackgroundWorker();
|
||||
BackgroundWorker forceServicesManual = new BackgroundWorker();
|
||||
|
||||
ServiceControl serviceControl = new ServiceControl();
|
||||
|
||||
|
||||
public StatusWindow()
|
||||
@@ -29,11 +32,23 @@ namespace VMwareLauncher
|
||||
delayWindowHide.Tick += DelayWindowHide_Tick;
|
||||
delayWindowHide.Interval = new TimeSpan(0, 0, 2);
|
||||
|
||||
forceServicesManual.DoWork += ForceServicesManual_DoWork;
|
||||
runProcess.DoWork += RunProcess_DoWork;
|
||||
loadServices.DoWork += LoadServices_DoWork;
|
||||
stopServices.DoWork += StopServices_DoWork;
|
||||
|
||||
delayWindowHide.Start();
|
||||
forceServicesManual.RunWorkerAsync();
|
||||
}
|
||||
|
||||
private void ForceServicesManual_DoWork(object sender, DoWorkEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
serviceControl.ForceServicesManual();
|
||||
}
|
||||
catch (Exception) { throw; }
|
||||
|
||||
loadServices.RunWorkerAsync();
|
||||
}
|
||||
|
||||
@@ -56,7 +71,18 @@ namespace VMwareLauncher
|
||||
sc.WaitForStatus(ServiceControllerStatus.Stopped);
|
||||
}
|
||||
}
|
||||
ApplicationControl.Shutdown(0);
|
||||
|
||||
// All 5 VMware Workstation services must be stopped to qualify
|
||||
// a successful shutdown.
|
||||
var stoppedVmServices = serviceControl.GetStoppedVmServices();
|
||||
if (stoppedVmServices.Count != 5)
|
||||
{
|
||||
ApplicationControl.Shutdown(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ApplicationControl.Shutdown(0);
|
||||
}
|
||||
}
|
||||
catch (Exception) { throw; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user