1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-09 23:25:43 +00:00

Add WaitHandle.WaitOneAsync

This commit is contained in:
Oliver Booth 2020-07-15 11:27:28 +01:00
parent 0b8d485514
commit e747921fb7

View File

@ -0,0 +1,21 @@
namespace X10D
{
using System.Threading;
using System.Threading.Tasks;
/// <summary>
/// Extension methods for <see cref="WaitHandle" />.
/// </summary>
public static class WaitHandleExtensions
{
/// <summary>
/// Returns a <see cref="Task" /> which can be awaited until the current <see cref="WaitHandle" /> receives a signal.
/// </summary>
/// <param name="handle">The <see cref="WaitHandle" /> instance.</param>
/// <returns>Returns a task which wraps <see cref="WaitHandle.WaitOne()" />.</returns>
public static Task WaitOneAsync(this WaitHandle handle)
{
return new Task(() => handle.WaitOne());
}
}
}