本文整理汇总了C#中ServiceStatus类的典型用法代码示例。如果您正苦于以下问题:C# ServiceStatus类的具体用法?C# ServiceStatus怎么用?C# ServiceStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServiceStatus类属于命名空间,在下文中一共展示了ServiceStatus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ServiceStatusEventArgs
internal ServiceStatusEventArgs(IServiceAddress serviceAddress, ServiceType serviceType, ServiceStatus oldStatus, ServiceStatus newStatus)
{
this.serviceAddress = serviceAddress;
this.serviceType = serviceType;
this.oldStatus = oldStatus;
this.newStatus = newStatus;
}
示例2: GetServiceStatus
private void GetServiceStatus()
{
if (service != null)
service.Refresh();
var ss = ServiceControl.GetServiceStatus(service);
if (ss != serviceStatus)
{
serviceStatus = ss;
DDnsSharpTray.SetStatus(serviceStatus);
string serviceStr;
switch (serviceStatus)
{
case ServiceStatus.Running:
serviceStr = "服务正在运行.";
break;
case ServiceStatus.Stopped:
serviceStr = "服务已停止.";
break;
case ServiceStatus.NotExist:
serviceStr = "服务尚未安装.";
break;
default:
serviceStr = "服务状态未知.";
break;
}
DDnsSharpTray.Current.Text = "DDnsSharp: " + serviceStr + "\r\n双击打开或隐藏界面.";
}
}
示例3: SetStatus
public static void SetStatus(ServiceStatus ss)
{
if (instance != null)
{
instance.Icon = iconDict[ss];
}
}
示例4: Service
// constructors
/// <summary>
/// Initializes a new instance of the <see cref="Service"/> class.
/// </summary>
protected Service()
{
this.status = (this is ServiceControllable) ? ServiceStatus.Stopped : ServiceStatus.Passive;
this.statusDate = DateTimeOffset.UtcNow;
this.log = new Logger(this.Name);
}
示例5: Start
public void Start()
{
Stop();
_timer = new Timer(5000);
_timer.Elapsed += TimerOnElapsed;
_timer.Start();
ServiceStatus = ServiceStatus.Started;
}
示例6: Stop
public void Stop()
{
if (_timer != null)
{
_timer.Stop();
_timer.Dispose();
_timer = null;
}
ServiceStatus = ServiceStatus.Stopped;
}
示例7: Resume
public void Resume()
{
Monitor.Enter(this.lockObject);
if (this.serviceStatus == ServiceStatus.Paused)
{
this.serviceStatus = ServiceStatus.Running;
}
Monitor.Exit(this.lockObject);
}
示例8: StopService
public void StopService()
{
try
{
SaveSettings();
}
finally
{
Status = ServiceStatus.Stopped;
}
}
示例9: DoStart
private void DoStart(string[] args)
{
if (m_verbose_messages)
m_eventLog.WriteEntry("Starting...");
lock(m_lock)
if (m_runner == null)
{
if (m_verbose_messages)
m_eventLog.WriteEntry("Set start time to 30 seconds...");
var sv = new ServiceStatus()
{
dwCurrentState = ServiceState.SERVICE_START_PENDING,
dwWaitHint = (int)TimeSpan.FromSeconds(30).TotalMilliseconds
};
SetServiceStatus(this.ServiceHandle, ref sv);
if (m_verbose_messages)
m_eventLog.WriteEntry("Starting runner...");
m_runner = new Runner(
m_cmdargs,
() =>
{
if (m_verbose_messages)
m_eventLog.WriteEntry("Started!");
var sv2 = new ServiceStatus()
{
dwCurrentState = ServiceState.SERVICE_RUNNING
};
SetServiceStatus(this.ServiceHandle, ref sv2);
},
() =>
{
if (m_verbose_messages)
m_eventLog.WriteEntry("Stopped!");
var sv2 = new ServiceStatus()
{
dwCurrentState = ServiceState.SERVICE_STOPPED
};
SetServiceStatus(this.ServiceHandle, ref sv2);
base.Stop();
},
(msg, important) =>
{
if (important || m_verbose_messages)
m_eventLog.WriteEntry(msg);
}
);
}
}
示例10: OnStop
protected override void OnStop()
{
// Update the service state to Start Pending.
ServiceStatus serviceStatus = new ServiceStatus();
serviceStatus.dwCurrentState = ServiceState.SERVICE_START_PENDING;
serviceStatus.dwWaitHint = 100000;
SetServiceStatus(this.ServiceHandle, ref serviceStatus);
eventLog1.WriteEntry("In onStop.");
// Update the service state to Running.
serviceStatus.dwCurrentState = ServiceState.SERVICE_RUNNING;
SetServiceStatus(this.ServiceHandle, ref serviceStatus);
}
示例11: SetServiceStatus
public static void SetServiceStatus(string name, ServiceStatus status)
{
switch (status)
{
case ServiceStatus.Started:
Start(name, StatusChangeTimeout);
return;
case ServiceStatus.Stopped:
Stop(name, StatusChangeTimeout);
return;
}
Debug.Assert(false, status.ToString());
}
示例12: Color
private ConsoleColor Color(ServiceStatus status)
{
switch (status)
{
case ServiceStatus.Pending :
return ConsoleColor.DarkYellow;
case ServiceStatus.Ok:
return ConsoleColor.Green;
case ServiceStatus.Fail:
return ConsoleColor.Red;
default:
throw new ArgumentOutOfRangeException(nameof(status), status, null);
}
}
示例13: StartService
public void StartService()
{
try
{
LoadSettings();
Status = ServiceStatus.Started;
}
catch
{
Status = ServiceStatus.Error;
throw;
}
}
示例14: OnStop
protected override void OnStop()
{
var serviceStatus = new ServiceStatus();
serviceStatus.dwCurrentState = ServiceState.SERVICE_STOP_PENDING;
serviceStatus.dwWaitHint = 10000;
SetServiceStatus(this.ServiceHandle, ref serviceStatus);
if (server != null) server.Stop();
if (dataServer != null) dataServer.Stop();
// Update the service state to Stopped.
serviceStatus.dwCurrentState = ServiceState.SERVICE_STOPPED;
SetServiceStatus(this.ServiceHandle, ref serviceStatus);
}
示例15: OnStart
protected override void OnStart(string[] args)
{
var serviceStatus = new ServiceStatus();
serviceStatus.dwCurrentState = ServiceState.SERVICE_START_PENDING;
serviceStatus.dwWaitHint = 10000;
SetServiceStatus(this.ServiceHandle, ref serviceStatus);
if (server != null) server.Start();
if (dataServer != null) dataServer.Start();
// Update the service state to Running.
serviceStatus.dwCurrentState = ServiceState.SERVICE_RUNNING;
SetServiceStatus(this.ServiceHandle, ref serviceStatus);
}