I have a class that created a threading .timer.
System.Threading.Timer timer;
TimerCallback cb = new TimerCallback(ProcessTimerEvent);
timer = new Timer(cb, reset, 1000, Convert.ToInt64(this.Interval.TotalSeconds));
}
private void ProcessTimerEvent(object obj)
{
if (Tick != null)
Tick(this, EventArgs.Empty);
}
I want dispose Timer inside of this and then timer work.
in my TickEvent i excecute a method but don’t complate this.
void MyTimer_Tick(object sender, EventArgs e)
{
if(value)
MyFunction();
}
Timer must be taken to stop until MyFunction complete.
I use this code.
TryEnter/Exit. No need to stop/restart the timer in that case; overlapping calls will not acquire the lock and return immediately.