本文整理汇总了C#中IService.Stop方法的典型用法代码示例。如果您正苦于以下问题:C# IService.Stop方法的具体用法?C# IService.Stop怎么用?C# IService.Stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IService
的用法示例。
在下文中一共展示了IService.Stop方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Stop
/// <summary>
/// Stop and log the specified service
/// </summary>
private static bool Stop(IService service)
{
bool success = false;
if ((object)service == null)
{
logger.Error("Failed to stop service: " + service.Name);
return false;
}
// Check if it's already stopped
if (!service.Running)
{
logger.IfInfo(" - Already stopped: " + service.Name);
return true;
}
if (service.Stop())
{
logger.IfInfo(" - Stopped: " + service.Name);
service.Running = false;
success = true;
}
else
{
logger.Error(" ! Failed to stop: " + service.Name);
}
return success;
}
示例2: Stop
private void Stop(IService service)
{
if (service == null) throw new ArgumentNullException("service");
try
{
Logging.Log.InfoFormat("Stopping service {0}", service.DisplayName);
service.Stop();
Logging.Log.InfoFormat("Service {0} stopped successfully", service.DisplayName);
}
catch (Exception ex)
{
Logging.Log.Error(string.Format("Failed stopping service {0}", service.DisplayName), ex);
}
}
示例3: ServiceStop
private static void ServiceStop(IService service)
{
try
{
service.Stop();
}
catch (Exception e)
{
service.StopException = e;
}
}