473,394 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Timer event doesn't get fired

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
Jun 27 '08 #1
9 1859
On Jun 16, 5:59 pm, eljainc <elja...@sbcglobal.netwrote:
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
Jun 27 '08 #2
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

On Jun 16, 11:59*am, eljainc <elja...@sbcglobal.netwrote:
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
Jun 27 '08 #3
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!
On Jun 16, 3:30*pm, qglyirnyf...@mailinator.com wrote:
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

On Jun 16, 11:59*am, eljainc <elja...@sbcglobal.netwrote:
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- Hide quoted text -

- Show quoted text -
Jun 27 '08 #4
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
Jun 27 '08 #5

"eljainc" <el*****@sbcglobal.netwrote in message
news:35**********************************@79g2000h sk.googlegroups.com...
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.


Jun 27 '08 #6
On Jun 16, 4:46 pm, "Mr. Arnold" <MR. Arn...@Arnold.comwrote:
"eljainc" <elja...@sbcglobal.netwrote in message

news:35**********************************@79g2000h sk.googlegroups.com...
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.
That's what I did. I used a designTime Timer control from the
toolbox.

Jun 27 '08 #7
On Jun 16, 4:46 pm, "Mr. Arnold" <MR. Arn...@Arnold.comwrote:
"eljainc" <elja...@sbcglobal.netwrote in message

news:35**********************************@79g2000h sk.googlegroups.com...
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.
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
Jun 27 '08 #8

"eljainc" <el*****@sbcglobal.netwrote in message
news:be**********************************@t54g2000 hsg.googlegroups.com...
On Jun 16, 4:46 pm, "Mr. Arnold" <MR. Arn...@Arnold.comwrote:
>"eljainc" <elja...@sbcglobal.netwrote in message

news:35**********************************@79g2000 hsk.googlegroups.com...
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.

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.

Jun 27 '08 #9
On Mon, 16 Jun 2008 16:04:20 -0700, eljainc <el*****@sbcglobal.netwrote:
[...]
Is there a Stopwatch replacement that will not cause conflicts with
the timer component?
As Jon said, until you post a complete code sample, there's no good way to
answer your question.

That said: I guarantee you that using the Stopwatch class is not causing
your issues. It simply measures passage of time. It doesn't delay
threads or cause other problems.

What _is_ a problem is calling Thread.Sleep() from a GUI thread, and given
that you seem to be using the System.Forms.Timer class, you are most
likely calling Thread.Sleep() from a GUI thread. If the GUI thread is
sleeping, the timer can't fire.

Of course, this is all speculation. Since you haven't posted a complete
code sample, there's really no way to know what's wrong with your code.

Pete
Jun 27 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Eli | last post by:
I'm developing a Visual Basic .Net app that interacts with Visio 2002. I have an event handler in VB to handle the Visio "SelectionChanged" event. This event handler is called when the event is...
3
by: Peter Johnsson | last post by:
How come the eventhandler for the timer's elapsed time event is called over and over again, even though the AutoReset property is set to false, if you assign a new value to the timer objects...
8
by: Daniel P. | last post by:
I'm trying to set a timer that gets called every 3 seconds so I can update a field in the UI with the time elapsed since the process started. What am I doing wrong that timerDF_Tick does not get...
9
by: HL | last post by:
I am using VS 2005 Beta - C# Problem: The Timer fires a few milliseconds before the actual Due-Time Let's say a timer is created in the following manner: System.Threading.Timer m_timer = null;...
7
by: Grahmmer | last post by:
I have a few timers that are added to a form at runtime. I can handle the event fine, but I cannot identify which timer fired. Is there a way to do this? Timer Creation: -------------...
7
by: Noozer | last post by:
I have a timer on a form. It isn't firing at all. I know that the timer is enabled, and that the interval is low (4000, which should be 4 seconds). To ensure the timer wasn't being inadvertantly...
4
by: Dan | last post by:
Hi, I have a timer on a form (System.Windows.Forms.Timer - Framework 1.1) that is set to 60 seconds as sort an of inactivity monitor. If 60 seconds have elapsed without any user activity I want...
10
by: Bob | last post by:
Okay, I've done this for years but now I'm going to question it just because this idea has been at the back of my head since I started using DotNet... My WinForms app queries a database every 60...
7
by: RobKinney1 | last post by:
Hello, Wow...I have one for you all and hopefully I am not understanding this timer object correctly. I have a timer setup that pulses a connection through a socket every 60 seconds. But it...
4
by: Boki | last post by:
Hi All, I have a timer, if my data queue Q has data, the timer should start work, if there is no data in Q, the timer should stop. However, there is an event can fire timer to start. Should I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.