Hmm...little confused on what do you want to achieve.
I can give a other way to handle more number of threads. Use ThreadPool instead.
c# Threading: How to manage stacking calls
Collapse
X
-
c# Threading: How to manage stacking calls
I have a timer T that launches an event on each tick:
Code:void t_Tick(object sender, EventArgs e) { System.Threading.Thread TickThread = new System.Threading.Thread(OnTick); TickThread.Start(); }
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.Code:private void OnTick() { lock (this) { System.Threading.Thread.Sleep(10000);//in reality some long process } }
cheers,
MattTags: None
Leave a comment: