System Events

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi.
I'm trying to handle the SessionEnding event in
Microsoft.Win32.SystemEvents, but when I hook up my event handler it throws
an exception. I don't recognize the exception and I'm not sure whether it has
anything to do with the fact I'm using it in a Windows Service. The exception
is given below.
Thanks for your assistance.
Reuben
=====================================================
System.Runtime.InteropServices.ExternalException: Failed to create system
events window thread.
at Microsoft.Win32.SystemEvents.EnsureSystemEvents(Boolean requireHandle,
Boolean throwOnRefusal)
at
Microsoft.Win32.SystemEvents.add_SessionEnding(SessionEndingEventHandler
value)
at Symbiosis.Symbiosis.OnStart(String[] args)
at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object
state).
 
Reuben said:
Hi.
I'm trying to handle the SessionEnding event in
Microsoft.Win32.SystemEvents, but when I hook up my event handler it throws
an exception. I don't recognize the exception and I'm not sure whether it has
anything to do with the fact I'm using it in a Windows Service. The exception
is given below.

I'm not sure it is necessary to hook the SessionEnding event in your
Windows Service. When Windows shuts down, the Service Control Manager
will stop your service. You should be able to do any necessary code in
the OnStop handler of your service.
 
Yes, but I need to be able to CANCEL the event if neccessary; hence the use
of the event.
 
Back
Top