On non-Windows platforms, WaitHandles 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.
On non-Windows platforms,
WaitHandles do not wrap kernel objects, but they are implemented in managed code. This means that it should be possible to implementRegisterWaitForSingleObjectby registering a callback directly on theWaitHandle, and queueing it to the thread pool when the wait handle gets signaled. With this and #131196, we can removePortableThreadPool.WaitThread.One complication would be with named cross-process mutexes which use shared memory, but
RegisterWaitForSingleObjectalready has unclear semantics when used with mutexes. We can throwNotSupportedExceptionin this case.