Stop timer
-
Hi, i have one button1 hwo starts the timer: Timer oT = new Timer(); oT.Tick+= new System.EventHandler(TimerFunction); oT.Interval = 15000; oT.Start(); private void TimerFunction(object o, EventArgs e) { //////////my code } My question is how do i stop the timer with a button2 click??? And do u know any good sleep or wait function??? Thanks!!!;);P:(
-
Hi, i have one button1 hwo starts the timer: Timer oT = new Timer(); oT.Tick+= new System.EventHandler(TimerFunction); oT.Interval = 15000; oT.Start(); private void TimerFunction(object o, EventArgs e) { //////////my code } My question is how do i stop the timer with a button2 click??? And do u know any good sleep or wait function??? Thanks!!!;);P:(
Hello,
andredani wrote:
My question is how do i stop the timer with a button2 click???
You found the "Start()" method, but not the "Stop()" method. :confused: Anyway, you could also set the Boolean "Enabled" property "true" or "false"!
andredani wrote:
And do u know any good sleep or wait function???
"Thread.Sleep(timeinms)" will freeze the thread (Also GUI if it's the main thread). Hope it helps!
All the best, Martin
-
Hi, i have one button1 hwo starts the timer: Timer oT = new Timer(); oT.Tick+= new System.EventHandler(TimerFunction); oT.Interval = 15000; oT.Start(); private void TimerFunction(object o, EventArgs e) { //////////my code } My question is how do i stop the timer with a button2 click??? And do u know any good sleep or wait function??? Thanks!!!;);P:(
You can use Enabled property for System.Timer or for System.Windows.Form.Timer
andredani wrote:
And do u know any good sleep or wait function???
Is it very difficult to guess that 'sleep' function is called Sleep()?
#region signature my articles #endregion
-
You can use Enabled property for System.Timer or for System.Windows.Form.Timer
andredani wrote:
And do u know any good sleep or wait function???
Is it very difficult to guess that 'sleep' function is called Sleep()?
#region signature my articles #endregion
Giorgi Dalakishvili wrote:
Is it very difficult to guess that 'sleep' function is called Sleep()?
Well, it might very well have been called "delay". :)