RE: Timers not fireing System.Windows.Forms.Timer and System.Timer

From: Tim (TimWard_at_nospam.nospam)
Date: 08/18/04


Date: Wed, 18 Aug 2004 03:07:04 -0700

Aye, Changed the code (including the Timers that hadn't shown issues yet) and
been testing all morning.... no problems.

So It does appear to be a bug with AutoReset set True - I think it also
requires you to be changing the enabled state (or Start/Stop) inside the
elapsed event.

Thanks for your help Pedro.
Cheers Tim

(Another .Net bug worked arround only ..... many more left!)

"Pedro Gonçalves" wrote:

> Hi Tim,
>
> I've a workaround for that. I think that is a bug, but....
>
> Use a Timers.Timer. Set AutoReset property to False.
> Then at the Elapse event, do what you want to do and at the end call your
> timer Start sub.
> This just do the same you were doing.
>
> To test the bug and solve it, just add code at the begin of the Elapse event
> that test if the Enabled property is True. If it is, that means that you just
> found that exact time where your timer would stop firing. Has you set
> AutoReset property to False the Enabled property should be False every time
> that Elapse event fires. In this case, just change the Enabled property to
> False.
>
> Your's Elapse event code should look like this:
>
> Private Sub myTimer_Elapsed(ByVal sender As Object, ByVal e As
> System.Timers.ElapsedEventArgs) Handles myTimer.Elapsed
>
> ''''''''''''''''''''''''''''''''
> ' Workaround para bug do timer '
> ''''''''''''''''''''''''''''''''
> If myTimer.Enabled Then
> myTimer.Enabled = False
> End If
>
> Try
>
> ' Just add your event response code here.
> Catch ex As Exception
> ' Handle Exception
> End Try
>
> cTimer.Start()
> End Sub
>
>
> "Tim" wrote:
>
> > I have a problem with a Winform application (VB.Net) that timers just stop
> > firing.
> >
> > I first used System.Windows.Forms.Timer - which failed very often so I
> > replaced them with System.Timers.Timer and all appeared Ok till someone
> > started using two copies of the applcaition at the same time.
> >
> > I have seen it fail in the IDE (with another instance run manually) - the
> > event just stops fireing. If I break the applcation and check the timer is
> > still enabled. If I add a button to stop then start the timer.. if starts
> > fireing again for a couple of times then stops again!
> >
> > I have found similar posts on the newgroups and net foums but havn't seen a
> > single answer yet!
> >
> > Regards
> > Tim
> >



Relevant Pages

  • RE: Timers not fireing System.Windows.Forms.Timer and System.Timers.Ti
    ... To test the bug and solve it, just add code at the begin of the Elapse event ... found that exact time where your timer would stop firing. ... AutoReset property to False the Enabled property should be False every time ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: ACPI PM-Timer on K6-3 SiS5591: Houston...
    ... this isn't the bug which is handled by the read-three-times-workaround. ... that handels the following PIIX4 errata: ... The power management timer may return improper results when read. ... Although the timer value settles properly after incrementing, ...
    (Linux-Kernel)
  • [patch] hrtimers debug patch
    ... I don't know how to reproduce this bug on 2.6.21-rc4. ... So to move this issue forward, i've written a hrtimers debug patch ... #ifdef CONFIG_HIGH_RES_TIMERS ... High resolution timer enabled? ...
    (Linux-Kernel)
  • Re: Tesing of / bugs in new timerfd API
    ... I found what looks like a bug (see ... CLOCK_REALTIME clock to expire in the past, ... (Nor is it consistent with the behavior of POSIX timers. ... Suppose that we set an absolute timer to expire 100 seconds ...
    (Linux-Kernel)
  • Re: Problem with System.Timers.Timer
    ... That happens because you set that timer to fire every 100 miliseconds. ... Timers.Timer fire Elapse event asyncron. ... If your handling code just take more that 100ms to process you will have ...
    (microsoft.public.dotnet.general)