Timers:
Script your own Timer class by having it subclass the base "Timer" class:
[code:1]public class MyTimer : Timer
{
}[/code:1]
Add a constructor passing in delay [, duration [, max exec count]]:
[code:1]public class MyTimer : Timer
{
// After 2.5 seconds, the timer will be ticked every 1.0 second. After 5 ticks, it will stop
public MyTimer() : base( TimeSpan.FromSeconds( 2.5 ), TimeSpan.FromSeconds( 1.0 ), 5 )
{
}
}[/code:1]
Override the protected OnTick event, and put whatever code you need in there:
[code:1]public class MyTimer : Timer
{
// After 2.5 seconds, the timer will be ticked every 1.0 second. After 5 ticks, it will stop
public MyTimer() : base( TimeSpan.FromSeconds( 2.5 ), TimeSpan.FromSeconds( 1.0 ), 5 )
{
}
protected override void OnTick()
{
// Whatever goes here
}
}[/code:1]
Now the timer class is scripted, all you need to do is start it.
[code:1]
Timer timer = new MyTimer();
timer.Start();
[/code:1]