Merge pull request #1936 from esdrubal/DotNetRelativeOrAbsolute
[mono.git] / mcs / class / corlib / coreclr / WaitHandleExtensions.cs
1 // Copyright (c) Microsoft. All rights reserved.
2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
4 //
5
6 using Microsoft.Win32.SafeHandles;
7 using System.Security;
8
9 namespace System.Threading
10 {
11     public static class WaitHandleExtensions
12     {
13         /// <summary>
14         /// Gets the native operating system handle.
15         /// </summary>
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>
18         [SecurityCritical]
19         public static SafeWaitHandle GetSafeWaitHandle(this WaitHandle waitHandle)
20         {
21             if (waitHandle == null)
22             {
23                 throw new ArgumentNullException("waitHandle");
24             }
25
26             return waitHandle.SafeWaitHandle;
27         }
28
29         /// <summary>
30         /// Sets the native operating system handle
31         /// </summary>
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>
34         [SecurityCritical]
35         public static void SetSafeWaitHandle(this WaitHandle waitHandle, SafeWaitHandle value)
36         {
37             if (waitHandle == null)
38             {
39                 throw new ArgumentNullException("waitHandle");
40             }
41
42             waitHandle.SafeWaitHandle = value;
43         }
44     }
45 }