Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi
When i run this code then nothing display on console but when i debug then it display the output.
Please explain why this happen? How i can get info when the Thread complete the task ?

C#
public class TestClass
 {
     static void Main()
     {
         ThreadPool.SetMaxThreads(5, 5);
         for (int x = 0; x < 10; x++)
         {
             ThreadPool.QueueUserWorkItem(new WaitCallback(printnum), x);
         }

         Console.ReadKey();
     }

     public static void printnum(object n)
     {
         Console.WriteLine("Call " + n);
         for (int i = 0; i < 10; i++) { Console.WriteLine(i); }
     }
 }
Posted
Comments
CPallini 19-May-14 6:10am    
Actually I see the full output on my system.
Sergey Alexandrovich Kryukov 19-May-14 11:21am    
Look at the tags: "ASP.NET"... :-)
—SA
Vi(ky 19-May-14 6:17am    
which .Net Framework you installed?
Avenger1 19-May-14 8:54am    
HiHere you are
http://msdn.microsoft.com/en-us/library/system.threading.threadpool(v=vs.110).aspx
With Respect "Spaceman"
Sergey Alexandrovich Kryukov 19-May-14 11:20am    
Console.ReadLine in ASP.NET? Are you serious? Or is it a wrong tag?
:-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900