-
March 29th, 2012, 05:16 PM
#1
How do I use a timer and a numericUpDown?
Hi I was wondering how do I use a timer and a numericUpDown that specifies the amount of seconds?
I just need the timer to make my program not do anything for a few seconds (but not freeze the interface) so I assume I wouldnt need to use the timer_tick event.
Do you guys know how to do this?
-
March 29th, 2012, 08:37 PM
#2
Re: How do I use a timer and a numericUpDown?
The timer will not do what you seem to be wanting. A timer fires an event every x milliseconds. Other objects continue to run as usual. To make to program stop for a period of time you would need to use the Sleep method of the Threading class.
Always use [code][/code] tags when posting code.
-
March 30th, 2012, 09:53 AM
#3
Re: How do I use a timer and a numericUpDown?
I tried this but it doesnt seem to be waiting the amount of time I specify in the numericUpDown:
Code:
timer1.Interval = Convert.ToInt32(numericUpDown2.Value * 1000);
timer1.Start();
-
March 30th, 2012, 10:14 AM
#4
Re: How do I use a timer and a numericUpDown?
I am testing this with a webBrowser, and want it to stop doing anything for the specified amount of time but even with the timer on, nothing stops
-
March 30th, 2012, 12:02 PM
#5
Re: How do I use a timer and a numericUpDown?
-
March 30th, 2012, 02:27 PM
#6
Re: How do I use a timer and a numericUpDown?
As I said a timer does not stop execution of your program. A timer fires an event every x milliseconds. If you wanted something to happen say in 30 seconds you could use a timer and place the code in the timer 30 seconds after the timer is enabled the code would execute. Other code will execute as it normally would timer will have no effect. To halt execution of code you must use Sleep. You can use a loop to keep code from going on but that is not always such a good idea.
A timer will not do what you wish.
Always use [code][/code] tags when posting code.
-
March 30th, 2012, 02:33 PM
#7
Re: How do I use a timer and a numericUpDown?
Oh , thanks for clearing that up.
Also, doesnt sleep freeze the whole gui?
-
March 30th, 2012, 06:00 PM
#8
Re: How do I use a timer and a numericUpDown?
Sleep freezes the thread that it is called on. If it is called on the GUI thread then yes it will freeze the GUI
Always use [code][/code] tags when posting code.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|