Timer event doesn't get fired

  • Thread starter Thread starter eljainc
  • Start date Start date
E

eljainc

Hello,

I'm having a problem with a simple application that I've written. I
have a form that loads another form. The second form has a timer
control on it. The timer will not fire for some reason. I have it
enabled and also used the start method. What might the problem be?

I've tried System.Windows.Forms.Timers and System.Timers but no luck.

Any help appreciated

Mike
 
I'm having a problem with a simple application that I've written. I
have a form that loads another form. The second form has a timer
control on it. The timer will not fire for some reason. I have it
enabled and also used the start method. What might the problem be?

I've tried System.Windows.Forms.Timers and System.Timers but no luck.

It's hard to say what's wrong with no code. Could you post a short but
complete program which demonstrates the problem?

See http://pobox.com/~skeet/csharp/complete.html for what I mean by
that.

Jon
 
Is this a windows application? Starts like:

Application.Run(new Form1());

or is this a Console application, if its a console application I don't
think the System.Windows.Forms.Timers will work, I think you will need
the:

System.Timers.Timer
 
Err... actually never mind.

but I think you may have problems if you run a timer that inherits
from Component on a console application or Windows server.... not
sure... time to do some research!
 
It seems that when I use the command

Thread.Sleep(xx)

in my code in the units that use the timers, this is when the problems
occur. I will need an alternate
to the Thread.Sleep() method. Is there anything else out there that
is similar?

Mike
 
eljainc said:
It seems that when I use the command

Thread.Sleep(xx)

in my code in the units that use the timers, this is when the problems
occur. I will need an alternate
to the Thread.Sleep() method. Is there anything else out there that
is similar?

I don't think you fully know how to use a spawned child thread that runs on
the Thread.Sleep method. I have never ever had a problem with the technology
with the execution of logic on a child thread on a timed basis.

Maybe, you should just drag a Timer control out of the Toolbox used for a
Windows Desktop form solution, place it on the form and use that Timer
control.
 
I don't think you fully know how to use a spawned child thread that runs on
the Thread.Sleep method. I have never ever had a problem with the technology
with the execution of logic on a child thread on a timed basis.

Maybe, you should just drag a Timer control out of the Toolbox used for a
Windows Desktop form solution, place it on the form and use that Timer
control.

That's what I did. I used a designTime Timer control from the
toolbox.
 
I don't think you fully know how to use a spawned child thread that runs on
the Thread.Sleep method. I have never ever had a problem with the technology
with the execution of logic on a child thread on a timed basis.

Maybe, you should just drag a Timer control out of the Toolbox used for a
Windows Desktop form solution, place it on the form and use that Timer
control.

The problem that occurs I found is when I mix the timer component with
the
System.Diagnostics.Stopwatch control. I would like to have multiple
timers
activated, but some timers I would like to use the .Elapsed property
of Stopwatch
so that I know how much time has passed instead of having an event
fire every xx
seconds or xx milliseconds.

Is there a Stopwatch replacement that will not cause conflicts with
the timer component?

Thanks
Mike
 
eljainc said:
The problem that occurs I found is when I mix the timer component with
the
System.Diagnostics.Stopwatch control. I would like to have multiple
timers
activated, but some timers I would like to use the .Elapsed property
of Stopwatch
so that I know how much time has passed instead of having an event
fire every xx
seconds or xx milliseconds.

Is there a Stopwatch replacement that will not cause conflicts with
the timer component?

I don't know. I have never used the Stopwatch. Maybe, you should just use a
Timer control in the Toolbox for form controls using the Tick event of the
Timer with the Stopwatch. Maybe, that will work for you.
 
Back
Top