Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Net HelpMsg 2189

1,390 views
Skip to first unread message

Vinay Kant

unread,
Apr 10, 2003, 6:24:15 PM4/10/03
to
Hello everyone...
I am doing a Windows Service. This service was meant to
process one file, but i am trying to make it process
multiple files. To do that i had to Unlock the object and
reset the event...Now, my multiple files is working but
when i try to mannually stop the service i get the
following message:
"The service could not be controlled in its present state"
More help is available by typing Net helpmsg 2189...

Has anyone any suggestions regarding this thing...
Any help will be highly appreciated...
Thank you...
Vinay Kant...

Joseph M. Newcomer

unread,
Apr 11, 2003, 1:26:22 AM4/11/03
to
Since you have not shown even the sketchiest code, it is not at all clear what you mean by
"unlock the object and reset the event". If you followed the standard model for a service,
there aren't any objects to lock or unlock and there aren't any events to be reset (there
is a SetEvent to do the shutdown). And all of the work of the service is done in
completely separate threads. This error (I typed in net helpmsg 2189) sounds like you have
locked up your ServiceCtrlHandler doing actual work, which the simplest explanation is
that this is always inappropriate. Because the ServiceCtrlHandler is tied up, you would
not be able to send additional requests to it. You need to show us a bit more about what
this strange phrase means and how your service is working.
joe

Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

Vinay Kant

unread,
Apr 11, 2003, 8:52:30 AM4/11/03
to
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:
BOOL CEWMNTService::WaitForStop (DWORD dwMilliSeconds)
{
return m_evStop.Lock (dwMilliSeconds);
}
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:
void CEWMNTService::ToUnlock ()
{
m_evStop.ResetEvent ();
m_evStop.Unlock ();
}
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.
Thanx a lot
Vinay Kant

>.
>

Joseph M. Newcomer

unread,
Apr 12, 2003, 1:49:59 AM4/12/03
to
The explanation is still not clear at all. See below

On Fri, 11 Apr 2003 05:52:30 -0700, "Vinay Kant" <vk...@solu-soft.com> wrote:

>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.
*****

nlg4...@gmail.com

unread,
Aug 3, 2016, 12:36:28 PM8/3/16
to
0 new messages