Click here to Skip to main content
15,885,985 members
Articles / Programming Languages / C#

Windows Service State Publisher

Rate me:
Please Sign up or sign in to vote.
4.88/5 (12 votes)
13 May 2004CPOL9 min read 70.2K   315   70  
Monitors Windows Services for changes in state using well known design patterns.
using System;

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

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

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

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

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

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
Dwight D. Eisenhower wrote: "In battle, I believe plans are useless; however, planning is indespensable."

Hmm, perhaps he was an early adopter of agile beliefs?! Wink | ;-)

Comments and Discussions