HElp needed to create a windows service , to launch a simple thread(win32)

Discussion in 'C' started by rag84dec, Dec 8, 2009.

  1. rag84dec

    rag84dec New Member

    Joined:
    Jul 17, 2007
    Messages:
    49
    Likes Received:
    0
    Trophy Points:
    0
    HElp needed to create a windows service , to launch a simple thread created by the user.
    I got an article here...

    http://www.devx.com/cplus/Article/9857/1954


    But how to create a thread at apropriate places , like STOP , RESUME , SHUTDOWN?.PLease
    give me some pointers ,

    thanks in advance...
     
  2. Gene Poole

    Gene Poole New Member

    Joined:
    Nov 10, 2009
    Messages:
    93
    Likes Received:
    5
    Trophy Points:
    0
    It really depends on the nature of your service. Typically a service should spend most of its time waiting for some sort of event. Your main thread should be in some sort of loop that polls for some sort of event, and if nothing is going on, it sleeps for some amount of time, then polls again. While in this loop of polling, you can check for mutexes (mutices?) or semaphores which can be set as a result of STOP, RESUME, or PAUSE with WaitForSingleEvent() or WaitForMultipleEvents() API calls.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice