Click here to Skip to main content
15,888,908 members
Articles / Programming Languages / C#

Create in-process asynchronous services in C#

Rate me:
Please Sign up or sign in to vote.
4.73/5 (27 votes)
6 Feb 20064 min read 129.5K   1.5K   138  
Use C# along with delegates, threads, and message queueing to create powerful in-process asynchronous services.
using System;

namespace WindowsApplication1
{
	/// <summary>
	/// Summary description for ServiceMessage.
	/// </summary>
	public class ServiceMessage
	{
		int state = 0;
		object o = null;

		public ServiceMessage(RunState State, object args)
		{
			state = (int)State;
			o = args;
		}

		public ServiceMessage(RunState State)
		{
			state = (int)State;			
		}

		public ServiceMessage(object args)
		{			
			o = args;
		}

		/// <summary>
		/// If not zero this property indicates the InprocessAsynchronousService should change handle a run state change
		/// </summary>
		public int ChangeToRunState
		{
			get
			{
				return state;
			}
		}

		/// <summary>
		/// Args to be passed on to the Heartbeat handlers
		/// </summary>
		public object Args
		{
			get
			{
				return o;
			}
		}
	}
}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
I have been coding since 4th grade in elementary school back in 1981. I concentrate mainly on Microsoft technologies from the old MSDOS/MSBASIC to coding in VC++ then Visual Basic and now .Net. I try to stay on top of the trends coming from Microsoft such as the Millennium Project, Windows DNA, and my new favorite Windows clustering servers.

I have dabbled in making games in my initial VC++ days, but spent most of the past 10 years working on business apps in VB, C++, and the past 7 years in C#.

I eventually hope to get my own company supporting me so I can concentrate on my real dream of creating clusters of automated robots for use in various hazardous industries.

Comments and Discussions