-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
There is no documentation for QueueUserWorkItem(Action, TState, Boolean) that explains what bool preferLocal does.
This was raised in an SO question What is ThreadPool.QueueUserWorkItem preferLocal for?.
The answer shows that the method was added by this pull request fixing this issue. The issue's text and Damien's answer are a good starting point :
The issue is described as:
ThreadPool.QueueUserWorkItem always queues to the global queue; however it would be good to have the option to be able to queue to the current threadpool thread's local queue when a threadpool thread queues extra work items.
...
When the Thread Pool was first built, it only had a single queue of work to be done. However, when all of the Task goodness was being plumbed into the framework, they took the opportunity to introduce thread-local queues (and work stealing) alongside what was now renamed the global queue. It looks like this is clean-up work to allow specific access to these queues.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 21ac9edb-6827-475d-30d3-cfd3b52c3028
- Version Independent ID: e13ed79b-e212-1d7a-f939-6086b300a399
- Content: ThreadPool.QueueUserWorkItem Method (System.Threading)
- Content Source: xml/System.Threading/ThreadPool.xml
- Product: dotnet-api
- GitHub Login: @dotnet-bot
- Microsoft Alias: dotnetcontent