However, the only way I can stop the servcie is press "shift-F5" , and this cannot help me much in debugging the right clean code.
Inside RunMessageLoop, my service is waiting for the ShutdownEvent , if running as a service, that event will be sent throgh the SCM (The SCM registered the handler function like this:
void Handler(DWORD dwOpcode) throw()
{
T* pT = static_cast
switch (dwOpcode)
{
case SERVICE_CONTROL_STOP:
pT->OnStop();
break;
case SERVICE_CONTROL_PAUSE:
pT->OnPause();
break;
case SERVICE_CONTROL_CONTINUE:
pT->OnContinue();
break;
case SERVICE_CONTROL_INTERROGATE:
pT->OnInterrogate();
break;
case SERVICE_CONTROL_SHUTDOWN:
pT->OnShutdown();
break;
default:
pT->OnUnknownRequest(dwOpcode);
}
}
But in debugging mode, the event can be simulated from a different process. This will rely on a named event, which can communicate between different processes.
No comments:
Post a Comment