OnShutdown() not working on XP
Posted
by
Daro
on Stack Overflow
See other posts from Stack Overflow
or by Daro
Published on 2011-11-22T17:10:18Z
Indexed on
2011/11/22
17:50 UTC
Read the original article
Hit count: 166
I have a service registered for shutdown events (.Net 3.5):
public ServiceName()
{
InitializeComponent();
base.CanHandleSessionChangeEvent = true;
base.CanHandlePowerEvent = true;
base.CanShutdown = true;
}
protected override void OnShutdown()
{
try
{
if (Program.Debug2Eventlog == true)
{
WriteEventEntry(
"Computer is shutting down.",
EventLogEntryType.Information, 0, 3);
}
}
catch
{}
base.OnShutdown();
}
Windows 7 logs the event just fine, but XP doesn't. Am I missing something?
© Stack Overflow or respective owner