本文整理汇总了C#中ServiceController.Continue方法的典型用法代码示例。如果您正苦于以下问题:C# ServiceController.Continue方法的具体用法?C# ServiceController.Continue怎么用?C# ServiceController.Continue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServiceController
的用法示例。
在下文中一共展示了ServiceController.Continue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PauseAndContinue
public void PauseAndContinue()
{
var controller = new ServiceController(_testService.TestServiceName);
Assert.Equal(ServiceControllerStatus.Running, controller.Status);
for (int i = 0; i < 2; i++)
{
controller.Pause();
controller.WaitForStatus(ServiceControllerStatus.Paused, _testService.ControlTimeout);
Assert.Equal(ServiceControllerStatus.Paused, controller.Status);
controller.Continue();
controller.WaitForStatus(ServiceControllerStatus.Running, _testService.ControlTimeout);
Assert.Equal(ServiceControllerStatus.Running, controller.Status);
}
}
示例2: ContinueService
/// <summary>
/// Continues the service.
/// </summary>
/// <param name="serviceName">Name of the service.</param>
/// <returns></returns>
public static bool ContinueService(string serviceName)
{
using (ServiceController sc = new ServiceController(serviceName))
{
if (sc.CanPauseAndContinue)
{
sc.Continue();
while (sc.Status != ServiceControllerStatus.ContinuePending)
{
Thread.Sleep(1000);
sc.Refresh();
}
if (sc.Status == ServiceControllerStatus.Running)
{
return true;
}
else
{
return false;
}
}
}
return false;
}