My Timer doesn't stop when I tell it to do so.

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi there,
I am using a Timer and it works fine, but when I tell it to stop, it doesnt. Maybe someone can help me in the right direction to solve my problem. This is my code:

<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; private <span style="color:Blue; void storingCheckBox_CheckedChanged(<span style="color:Blue; object sender, EventArgs e)
{
System.Timers.Timer timer = <span style="color:Blue; new System.Timers.Timer();
timer.Interval = 1000;

<span style="color:Blue; if (storingCheckBox.Checked == <span style="color:Blue; true)
{
timer.Start();
}

<span style="color:Blue; if(storingCheckBox.Checked == <span style="color:Blue; false)
{
timer.Stop();
}

}
<span style="color:Blue; public <span style="color:Blue; void OnTimedEvent(<span style="color:Blue; object source, ElapsedEventArgs e)
{
Cpu cpu = <span style="color:Blue; new Cpu(autoNZ, autoOW, fietsNZ, fietsOW, zebraNZ, zebraOW);
Graphics g = Graphics.FromHwnd(<span style="color:Blue; this.Handle);
cpu.setStoring(g);
}
[/code]
<br/>
<br/>



View the full article
 
Back
Top