EventLog Class

M

McKool

Hello.

I'm making a Windows service with C#. This service connect a comm Port when
start and disconnect it when stop. I use an EventLog class to write
information about this service, by example, when the port get connect or
disconnect.

All work ok until the moment when the computer shutdown. If I stop the
service manually before window shutdown, there is not any problem. If the
service still run and windows is shutting down, the computer hang on after
terminate all programs and services (after the window message box "Windows
is being shutting down"). Only what I can see is the Mouse pointer and the
blue screen. If I do not use the EventLog class, the computer shutdown OK.

Every time when i use the Event log make something like:

MyEvents.WriteEntry(System.String.Format("Error: {0}",strError));
MyEvents.Close();

What can i doing wrong?

Thanks in advance....
KW
 
G

Guest

Hi,

You have an event on the windows service that detects when the machine is
shutting down, if this event is triggered dump whatever is necessary and do
not dump it on the OnStop event.

protected override void OnShutdown()
{
base.OnShutdown ();
}
hope this helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top