Home All Groups Group Topic Archive Search About

Windows Service using System.Threading.Timer and Windows AutoUpdate (XP)

Author
5 Jul 2006 4:17 PM
Brent Dunham
Hello,
I've written a C# Windows service that starts a System.Threading.Timer that
should fire every minute. It has been working perfectly until Windows Update
applied some updates. Once this happened (on all machines running this
service) the timer stops firing. This has cuased some issues with out
company as this is a pretty important service. Has anyone ran into this or
have knowledge of this issue?


Here s code for Service Start
/// <summary>

/// Set things in motion so your service can do its work.

/// </summary>

protected override void OnStart(string[] args)

{

bool success = true;


try

{

_Interval =
double.Parse(System.Configuration.ConfigurationSettings.AppSettings["Interval"]);

}

catch(Exception ex)

{

System.Diagnostics.EventLog.WriteEntry("FSAClaimsCalcService","Unable to
determine Interval: " +
ex.Message,System.Diagnostics.EventLogEntryType.Error);

success = false;

}


try

{

_ServerID =
int.Parse(System.Configuration.ConfigurationSettings.AppSettings["ServerID"]);


}

catch(Exception ex)

{

System.Diagnostics.EventLog.WriteEntry("FSAClaimsCalcService","Unable to
determine ServerID: " +
ex.Message,System.Diagnostics.EventLogEntryType.Error);

success = false;

}

try

{

_LoggingEnabled =
bool.Parse(System.Configuration.ConfigurationSettings.AppSettings["LoggingEnabled"]);


}

catch(Exception ex)

{

System.Diagnostics.EventLog.WriteEntry("FSAClaimsCalcService","Unable to
determine LoggingEnabled: " +
ex.Message,System.Diagnostics.EventLogEntryType.Error);

success = false;

}

if(success)

{

_Worker = null;

_Worker = CreateWorker();

_Timer = new System.Threading.Timer(new
System.Threading.TimerCallback(Timer_Elapsed),null,1000,(long)(.5 * 1000 *
60));

}

}





Here is the other Elapse Code and Stop code:

private void Timer_Elapsed(object state)

{

if(_Worker!=null && !_Worker.Running)

{

_Worker = null;

_Worker = CreateWorker();

System.Diagnostics.Debug.WriteLine("Worker not working. Launching");

_Worker.Start();

}

else

{

System.Diagnostics.Debug.WriteLine("Worker still working.");

}

}

/// <summary>

/// Stop this service.

/// </summary>

protected override void OnStop()

{

_Timer.Dispose();

}

Author
5 Jul 2006 5:36 PM
John Duval
Hi Brent,
You might want to check out this article:
FIX: When a .NET Framework based application uses the
System.Threading.Timer class, the timer event may not be signaled in
the .NET Framework 1.1 SP1

http://support.microsoft.com/?id=900822

John
Author
5 Jul 2006 5:55 PM
Brent Dunham
Thanks for the feedback John.
I will look into this. It sounds like this is likely it.
I will post back and let everyonek now.
thanks,
Brent

Show quote
"John Duval" <JohnMDu***@gmail.com> wrote in message
news:1152121008.895436.314590@75g2000cwc.googlegroups.com...
> Hi Brent,
> You might want to check out this article:
> FIX: When a .NET Framework based application uses the
> System.Threading.Timer class, the timer event may not be signaled in
> the .NET Framework 1.1 SP1
>
> http://support.microsoft.com/?id=900822
>
> John
>

AddThis Social Bookmark Button