Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brent Dunham - 05 Jul 2006 17:17 GMT
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();

}
John Duval - 05 Jul 2006 18:36 GMT
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
Brent Dunham - 05 Jul 2006 18:55 GMT
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

> Hi Brent,
> You might want to check out this article:
[quoted text clipped - 5 lines]
>
> John

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.