I have a question regarding the "Timer" code setup provided in the "CustomEvents" Sampler. The setup for a timer is provided as something similar to this:
//in "Variables"
private System.Windows.Forms.Timer myTimer = new System.Windows.Forms.Timer();
//in "OnBarUpdate"
if (CurrentBar == 0)
{
// Initiate our Timer object with an interval of 120000ms (2 minutes)
myTimer.Tick += new EventHandler(TimerEventProcessor);
myTimer.Interval = 120000;
myTimer.Start();
}
I'm using this code and it seems to work fine. My one issue is, however, that a new instance of the event is added each time (every 2 minutes). Thus the first time the Timer runs everything is fine, 2 minutes later the event is called twice, 2 minutes later the event is called 3 times, 2 minutes later the event is called 4 times...etc
How do I prevent additional instances from being called each run? Is a variable needed or is it something with that code above?
Comment