Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   HElp needed to create a windows service , to launch a simple thread(win32) (http://www.go4expert.com/forums/help-create-windows-service-launch-t20312/)

rag84dec 8Dec2009 18:58

HElp needed to create a windows service , to launch a simple thread(win32)
 
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...

Gene Poole 8Dec2009 20:15

Re: HElp needed to create a windows service , to launch a simple thread(win32)
 
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.


All times are GMT +5.5. The time now is 20:02.