new WaitCallback : WaitCallback : Thread C# Source Code


Custom Search

C# Source Code » Thread » WaitCallback »

 

new WaitCallback








    
 
using System;
using System.Threading;

class ThreadPoolDemo {
    public void LongTask1(object obj) {
        for (int i = 0; i <= 999; i++) {
            Console.WriteLine("Long Task 1 is being executed");
        }
    }
    public void LongTask2(object obj) {
        for (int i = 0; i <= 999; i++) {
            Console.WriteLine("Long Task 2 is being executed");
        }
    }

    static void Main() {
        ThreadPoolDemo tpd = new ThreadPoolDemo();
        for (int i = 0; i < 50; i++) {
            ThreadPool.QueueUserWorkItem(new WaitCallback(tpd.LongTask1));
            ThreadPool.QueueUserWorkItem(new WaitCallback(tpd.LongTask2));
        }

        Console.Read();
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Thread
» WaitCallback