mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-23 00:18:47 +00:00
✨ Add WaitHandle.WaitOneAsync
This commit is contained in:
parent
0b8d485514
commit
e747921fb7
21
X10D/src/WaitHandleExtensions.cs
Normal file
21
X10D/src/WaitHandleExtensions.cs
Normal 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());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user