Click here to Skip to main content
11,921,354 members (61,916 online)
Click here to Skip to main content
Add your own
alternative version


23 bookmarked

Multi-threaded polling process - base for NT-Service

, 23 Mar 2003
Rate this:
Please Sign up or sign in to vote.
This is a simple skeleton for a multi-thread process or services
<!-- Download Links --> <!-- Article image -->

Sample Image - PGThreads.gif

<!-- Add the rest of your HTML here -->


This sample code may be use as a basic skeleton for a multi-threaded process or service.

Background (optional)

Article "A simple tutorial on Multithreaded Programming using C#" from Zeeshan Amjad may be useful for beginners.

Using the code

To use the code:

  • create a new Console Application (or a Windows Services),
  • Replace [STAThread] attribute by [MTAThread] attribute of the Main method (for Console Application),
  • add WorkerThread.cs and WorkerThreadManager.cs files to your projet,
  • modify the DoSomethingUseful method by providing your task,
  • create a new WorkerThreadManager,
  • call Start / Stop methods.

That's it.

Example of basic main method:

// Any source code blocks look like this
static void Main(string[] args)
    String sCmd; WorkerThreadManager oManager = new WorkerThreadManager();

    for (;;)
        Console.Write("$ "); 
        sCmd = Console.ReadLine ();
        if (sCmd.ToUpper() == "EXIT")
            // Stop manager and exit loop
            // oManager.Stop();

        if (sCmd.ToUpper() == "START")
            // Start manager
            // oManager.Start();
        else if (sCmd.ToUpper() == "STOP")
            // Stop manager
            // oManager.Stop();

Points of Interest

This code is the basic skeleton of one of our high availability SMS (Short Message System) platform. It actually handles a couple of million of SMS per month on a 24/7 basis. 


  • 24th March, 2003 - First revision.


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


About the Author

Web Developer
France France
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionInfo about this kind of project Pin
JLuisEstrada26-Apr-07 8:42
memberJLuisEstrada26-Apr-07 8:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.151120.1 | Last Updated 24 Mar 2003
Article Copyright 2003 by pgrenette
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid