Use System.Threading.Timer instead.
A couple things to know:
1. Use the Timer constructor wisely:
public Timer(2. Use Change method to Stop/Restart the timer:
TimerCallback callback, // create a private void method with only stateInfo
// argument (the method signature is essential)
Object state, // can be null if you do not plan to use a sync object
int dueTime, // delay before first timer event gets fired
int period // timer event interval - what else
)
public bool Change(3. Do not forget to Dispose() the timer when it is no more required
int dueTime, // set Timeout.Infinite to stop the timer or smth else to continue
int period // see above
)
Enjoy!
No comments:
Post a Comment