I have the following code:
var items = new List {\"1\", \"2\", \"3\"}; // 200 items
foreach(var item in items) {
ThreadPool.QueueUserWorkItem
The following note from MSDN documentation on ThreadPool says it all:
The threads in the managed thread pool are background threads. That is, their
IsBackground
properties are true. This means that aThreadPool
thread will not keep an application running after all foreground threads have exited.
Your application simply exits (by reaching end of Main
) before your threads finish running.