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

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

}
 
B

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
 

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

Top