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

rag84dec's Avatar, Join Date: Jul 2007
Go4Expert Member
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...
0
Gene Poole's Avatar, Join Date: Nov 2009
Contributor
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.