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