I have a timer T that launches an event on each tick:
Now, imagine the sleep is longer than the tick-time. I am assuming that the threads will start stacking up waiting for the lock to clear. How do I go about discarding/ignoring calls until the lock is cleared.
cheers,
Matt
Code:
void t_Tick(object sender, EventArgs e)
{
System.Threading.Thread TickThread = new System.Threading.Thread(OnTick);
TickThread.Start();
}
Code:
private void OnTick()
{
lock (this)
{
System.Threading.Thread.Sleep(10000);//in reality some long process
}
}
cheers,
Matt
Comment