Maximum queued elements in ThreadPool.QueueUserWorkItem

后端 未结 4 1734
醉梦人生
醉梦人生 2020-12-31 18:19

I set the max thread to 10. Then I added 22000 task using ThreadPool.QueueUserWorkItem. It is very likely that not all the 22000 task was completed after running the program

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-31 19:09

    From the documentation of ThreadPool:

    Note: The threads in the managed thread pool are background threads. That is, their IsBackground properties are true. This means that a ThreadPool thread will not keep an application running after all foreground threads have exited.

    Is it possible that you're exiting before all tasks have been processed?

提交回复
热议问题