1 // Copyright (c) Microsoft. All rights reserved.
2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
6 using Microsoft.Win32.SafeHandles;
9 namespace System.Threading
11 public static class WaitHandleExtensions
14 /// Gets the native operating system handle.
16 /// <param name="waitHandle">The <see cref="System.Threading.WaitHandle"/> to operate on.</param>
17 /// <returns>A <see cref="System.Runtime.InteropServices.SafeHandle"/> representing the native operating system handle.</returns>
19 public static SafeWaitHandle GetSafeWaitHandle(this WaitHandle waitHandle)
21 if (waitHandle == null)
23 throw new ArgumentNullException("waitHandle");
26 return waitHandle.SafeWaitHandle;
30 /// Sets the native operating system handle
32 /// <param name="waitHandle">The <see cref="System.Threading.WaitHandle"/> to operate on.</param>
33 /// <param name="value">A <see cref="System.Runtime.InteropServices.SafeHandle"/> representing the native operating system handle.</param>
35 public static void SetSafeWaitHandle(this WaitHandle waitHandle, SafeWaitHandle value)
37 if (waitHandle == null)
39 throw new ArgumentNullException("waitHandle");
42 waitHandle.SafeWaitHandle = value;