Support registering wait handle callbacks in the managed wait subsystem.
Open
area-System.Threading
- Dominant language
- C#
- Stars
- 18.3k
- Forks
- 5.6k
- PR merge metrics
- PR metrics pending
Description
On non-Windows platforms, `WaitHandle`s do not wrap kernel objects, but they are implemented in managed code. This means that it should be possible to implement `RegisterWaitForSingleObject` by registering a callback directly on the `WaitHandle`, and queueing it to the thread pool when the wait handle gets signaled. With this and #131196, we can remove `PortableThreadPool.WaitThread`.
One complication would be with named cross-process mutexes which use shared memory, but `RegisterWaitForSingleObject` already has unclear semantics when used with mutexes. We can throw `NotSupportedException` in this case.
Contributor guide
Assessment
This issue has not been assessed yet.