1

Does anyone have an example of this, I've been trying for days and I can't figure it out.

Help...

Here is one of the things I've tried:

var aTimer = new System.Timers.Timer(10000);
aTimer.add_Elapsed(handler);
}

public function handler(sender: Object, e : ElapsedEventArgs){ }
Cheran Shunmugavel
  • 8,319
  • 1
  • 33
  • 40
Mitchell
  • 929
  • 2
  • 11
  • 34
  • I hope you don't mind my retagging. The jscript tag tends to be used more for the scripting variant of JScript, not for .NET development. Hopefully this gets your question more visibility. – Cheran Shunmugavel May 24 '12 at 06:06

1 Answers1

2

Your aTimer object appears to be a local variable within a function, which means that it may get garbage collected. Try moving it to a field in your class.

Also, after you set the Elapsed property, you need to start the timer:

aTimer.Start();
Simon MᶜKenzie
  • 8,344
  • 13
  • 50
  • 77