⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 servicestopped.cs

📁 Oracle Service Manager
💻 CS
字号:
using System;
using System.Diagnostics;
using System.ServiceProcess;
using System.Threading;

namespace kae.ServiceStatePublisher
{
	/// <summary>
	/// ServiceStopped is a concrete ServiceState representing the 
	/// ServiceController state of stopped.  As a singleton, only 
	/// one instance of this class is needed for the application.
	/// </summary>
	public class ServiceStopped : ServiceState
	{
		private static ServiceStopped _instance;

		static ServiceStopped()
		{
			lock (typeof(ServiceStopped))
			{
				if (_instance == null)
					_instance = new ServiceStopped();
			}
		}

		public static ServiceStopped Instance
		{
			get { return _instance; }
		}

		public override void Start( ServiceContext context)
		{
			try
			{
				context.Controller.Start();
				context.Controller.WaitForStatus( ServiceControllerStatus.Running, new TimeSpan(0,0,30));
				ChangeState( context, ServiceRunning.Instance);
			}
			catch (TimeoutException te)
			{
				LogError( te.Message, EventLogEntryType.Warning);
				throw;
			}
		}

		public override string Status
		{
			get { return "Stopped"; }
		}

		public override bool IsStopped
		{
			get { return true; }
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -