Bug with Timers?

G

Guest

I'm having trouble implementing one of my standard timer
strategies. Because the code for a timer might take an
unspecified amount of time, in VB 6 I disabled the timer
until the timer event code completed.

Now in .NET I'm seeing the timer fire twice in succession,
even though the timer interval is long (1-4 seconds). A
simple project doesn't have this problem, but as more an
more complex it gets, it seems the timer goes haywire.

This is the code I'm using for the timer event is

tmrTurn.Enabled = False
RunMyCode()
Me.stbMain.Text = CurrentDate & " " & CurrentTime
Me.stbMain.Refresh()
tmrTurn.Enabled = True

There are no other references to tmrTurn and this is the
other timer. Doesn't matter the interval, it will always
fire twice before tmrTurn.Enabled=False is executed.

Using VS2003.
 
D

Dick Grier

Hi,

I have checked... And, on my system, I get just the single timer event.
Setting the Enabled property to False works as expected.

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 3rd
Edition ISBN 1-890422-27-4 (391 pages) published February 2002.
 

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