Has anyone any suggestions regarding this thing...
Any help will be highly appreciated...
Thank you...
Vinay Kant...
Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
>.
>
>Joe,
>My mistake...i was not clear enough...
>okay..heres the declaration of my manual event:
>m_evStop (FALSE, TRUE)
>From the main program i am calling a function with this
>code to do the processing of my file again and again:
*****
There is no "main program" worth speaking of in a service. There is the
ServiceCtrlHandler, and ServiceMain, but neither are construable as a "main program"
*****
>BOOL CEWMNTService::WaitForStop (DWORD dwMilliSeconds)
>{
> return m_evStop.Lock (dwMilliSeconds);
>}
*****
I wouldn't touch an MFC synchronization primitive with a ten-foot pole. But again, it is
not clear what the context is here. You "lock" an event (whatever THAT means, since events
can never be "locked", they are only "Set" or "Reset", more MFC stupidity about
synchronization primitives). And to wait for a time, you do WaitForSingleEvent on an
event. I refuse to deal with MFC synchronization events because they bear no resemblance
to actual semantics of the objects, particularly those dealing with events.
*****
>This service was previously handling processing single
>file, but now i am making it to process multiple files, so
>in the main program i am looping as many times.
>but in the above code as you can see the event is locked,
>i have to reset the event, to do that i am calling a
>function:
*****
Neither of these communicate anything at all. So you reset an event. Then you unlock it. I
do NOT understand this at all. Get rid of the MFC event nonsense and use HANDLE objects
and real primitives. Then it might be comprehensible.
*****
>void CEWMNTService::ToUnlock ()
>{
> m_evStop.ResetEvent ();
> m_evStop.Unlock ();
>}
*****
And none of this explains WHY you are doing the locking, what you are calling it from,
what thread is being stopped, or anything else that could help diagnose the problem.
*****
>Now this is helping me to process multiple files, but i am
>not able to mannually stop the service, which i could do
>before.
>If you need whole code i can email it to you.
>I would really appreciate any suggestions.
*****
It would help, but I'm out of town for a week. I strongly suspect you have simply done the
wrong thing by putting the actual processing code in your ServiceCtrlHandler (or functions
called from it); the real processing MUST be done in a thread (or threads) completely
separate from the thread that is the ServiceCtrlHandler. That is, the ONLY things a
ServiceCtrlHandler is allowed to do are operations that are non-blocking and very fast. No
loops, for example, and definitely, under no circumstances, ANYTHING that could block!
Otherwise, the problems you are describing could exist.
*****