[corlib] Fix potential RegisteredWaitHandle resource leak
If we construct RegisteredWaitHandle with executeOnlyOnce = true, and never call Unregister, we will keep _waitObject.SafeWaitHandle reference count unbalanced. This will lead to never releasing the waitObject handle.
As we only need to ensure that the waitObject handle is alive while in the Wait method, we use the SafeHandle mechanism only there. The 2 possibles scenarios in the Wait method are:
- waitObject has not been closed: we increment its ref count, so we ensure that it's alive as long as we use it here
- waitObject has been closed: a ObjectDisposedException is thrown, we catch it and keep on without trying to wait on the handle