B
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();
}
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();
}