Since Windows 8, the Windows thread pool has been able to serve an unbounded number of wait callbacks with a single thread, by using the NtAssociateWaitCompletionPacket API to register wait handle completion packets on an I/O completion port. We can make use of this API in the portable thread pool, by leveraging its existing I/O completion port. Other environments like Go and Bun are using it too.
If it's OK to do, should we keep the existing PortableThreadPool.WaitThread mechanism as a fallback if NtAssociateWaitCompletionPacket does not exist? It should exist on all Windows versions currently supported by .NET, barring potential outliers like Xbox.
Since Windows 8, the Windows thread pool has been able to serve an unbounded number of wait callbacks with a single thread, by using the
NtAssociateWaitCompletionPacketAPI to register wait handle completion packets on an I/O completion port. We can make use of this API in the portable thread pool, by leveraging its existing I/O completion port. Other environments like Go and Bun are using it too.If it's OK to do, should we keep the existing
PortableThreadPool.WaitThreadmechanism as a fallback ifNtAssociateWaitCompletionPacketdoes not exist? It should exist on all Windows versions currently supported by .NET, barring potential outliers like Xbox.