C# Removing a timer after adding it with Timer.Elapsed -


i have little problem here. i'm starting 1 timer @ start of application using this:

if (initialized == 0) {     errorchecktimer.elapsed += (sender, e) => onerrorchecktimerelapsed(sender, e);     initialized = 1; } 

it makes sure it's started 1 time. if execute line more once, timer fire multiple times , once.

now after initializing timer, occassionally run using:

errorchecktimer.interval = errortimerinterval; errorchecktimer.enabled = true; errorchecktimer.start(); 

and after actions happen, stop with:

tradeerrortimer.enabled = false; tradeerrortimer.stop(); 

but there obscure glitch happening. timer works when firstly initialized, not turn on @ all, , onerrorchecktimerelapsed not executed.

therefore make more reilable, can remove timer has been added onerrorchecktimerelapsed.elapsed initialize new 1 every time need start it?

if try initialize them multiple times, onerrorchecktimerelapsed firing multiple times @ once.

thank you.

if don't want run timer more once, should set autoreset property false. errorchecktimer.autoreset = false;


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -