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
Post a Comment