linux-packaging-mono/mcs/class/corlib/coreclr/WaitHandleExtensions.cs
Xamarin Public Jenkins f3e3aab35a Imported Upstream version 4.3.2.467
Former-commit-id: 9c2cb47f45fa221e661ab616387c9cda183f283d
2016-02-22 11:00:01 -05:00

45 lines
1.6 KiB
C#

// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using Microsoft.Win32.SafeHandles;
using System.Security;
namespace System.Threading
{
public static class WaitHandleExtensions
{
/// <summary>
/// Gets the native operating system handle.
/// </summary>
/// <param name="waitHandle">The <see cref="System.Threading.WaitHandle"/> to operate on.</param>
/// <returns>A <see cref="System.Runtime.InteropServices.SafeHandle"/> representing the native operating system handle.</returns>
[SecurityCritical]
public static SafeWaitHandle GetSafeWaitHandle(this WaitHandle waitHandle)
{
if (waitHandle == null)
{
throw new ArgumentNullException("waitHandle");
}
return waitHandle.SafeWaitHandle;
}
/// <summary>
/// Sets the native operating system handle
/// </summary>
/// <param name="waitHandle">The <see cref="System.Threading.WaitHandle"/> to operate on.</param>
/// <param name="value">A <see cref="System.Runtime.InteropServices.SafeHandle"/> representing the native operating system handle.</param>
[SecurityCritical]
public static void SetSafeWaitHandle(this WaitHandle waitHandle, SafeWaitHandle value)
{
if (waitHandle == null)
{
throw new ArgumentNullException("waitHandle");
}
waitHandle.SafeWaitHandle = value;
}
}
}