c# Threading: How to manage stacking calls

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • matthewaveryusa
    New Member
    • Jul 2008
    • 20

    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();
            }

    Code:
            private void OnTick()
            {
                lock (this)
                {
                    System.Threading.Thread.Sleep(10000);//in reality some long process
                }
            }
    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
  • Ramk
    New Member
    • Nov 2008
    • 61

    #2
    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.

    Comment

    Working...