I am trying to use ThreadPool in C# Console application as shown below.
- static void Main(string[] args)
- {
- for (var i = 1; i<= 10; i++)
- {
- ThreadPool.QueueUserWorkItem(n =>
- {
- Console.WriteLine($"Start operation {n}");
- Thread.Sleep(1000); // Simulate long running operation
- Console.WriteLine($"Operation {n} completed");
- }, i);
- }
- Console.ReadKey();
- }
The type or namespace name "QueueUserWorkItem" does not exist in the namespace "ThreadPool".
What I am doing wrong or which reference I need to add. I have already used the namespace system.Threading.
I am working on .Net framework version 4.6.

Suraj KumarPosted Jun 1, 2019, 3:56 AM