Problems using System.Threading.Timer

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Michael Groeger (google.news_at_web.de)
Date: 09/20/04


Date: 20 Sep 2004 09:10:20 -0700

Hi NG,

I am a little bit confused about System.Threading.Timer. I am using
two Timer objects which control uptime of my apps. One is used to
notify my apps to suspend and one is used to notify them to resume.

One of my apps is running from 7am to 22pm. Under normal
circumstances, it works fine. I'll receive one event at 22pm and one
again at 7am. When starting the app the time till 7am/22pm is
calculated and set as dueTime parameter and the period parameter is
set to 1 day.

Under any other circumstance - which I can't define, because I don't
really have an idea what happens - the timer callback for the resume
time is invoked periodically ... at any time ... in any other period
than 1 day ...
So far, so good. But the thing is getting even more weird when closing
the application and starting it up again: the timer seems still to be
confused.

I started to change the values of dueTime and period to 1 Minute and 1
second. The timer callback was invoked as expected... first after 1
minute and then every second. Changing the values back again ended up
in permanent callback invokations.

Then, I tried a second application which was used for testing purposes
of my Uptime Management component. I set the values to the same values
as in my normal application. Now, the callback for the resume timer
was invoked once immediately but then it seemed to work correctly.

Okay, now the "funny" part: after rebooting, the same component using
the same values worked for both applications as expected. Until the
next time "any under circumstance" happens ...

I have digged deep into the microsoft ng's, but without finding a
solution or even somebody having the same problem.

Can somebody help with this? Is there anybody out there having similar
problems?

Kind regards,
Michael



Relevant Pages

  • Re: Dual core Athlons and unsynced TSCs
    ... >>> timer instead. ... It doesn't solve the problem for apps or other kernel bits ... >> if the kernel can't keep reasonable time on these machines. ... > I never tried it with pmtimer, we had HPET available. ...
    (Linux-Kernel)
  • Re: Experimental ntpd for Windows
    ... Unfortunately you don't know in advance which other apps set the MM timer ... IMHO any patch which enhances the clock discipline under Vista is welcome as ...
    (comp.protocols.time.ntp)
  • Re: Raiseevents failed to raise within timer control and XP SP2
    ... > need the timer as it keeps my activex alive as well as my exe. ... I can tell which apps are "listening" and catching ... Interfaces are "hard wired" in, ...
    (microsoft.public.vb.bugs)
  • Re: Timed event - problem
    ... is the timer callback in a different thread than the main prog ... equivalent to using a polling loop and defeats the purpose of using a timer. ... And can a timer callback be called while we are still in a different timer ... I believe a timer callback function is just a function. ...
    (comp.unix.programmer)
  • Re: Thread Pooling when using SoapService & SoapClient
    ... > coming from the message receive timeout engine which is not transport ... > is creating and destroying a thread to handle the timer callback. ...
    (microsoft.public.dotnet.framework.webservices.enhancements)