mirror of https://github.com/oliverbooth/X10D
(#42) Validate not-null handle
This commit is contained in:
parent
49ed44100d
commit
4828300076
|
@ -1,4 +1,5 @@
|
||||||
using System.Threading;
|
using System;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace X10D
|
namespace X10D
|
||||||
|
@ -15,7 +16,12 @@ namespace X10D
|
||||||
/// <returns>A task which encapsulates <see cref="WaitHandle.WaitOne()" />.</returns>
|
/// <returns>A task which encapsulates <see cref="WaitHandle.WaitOne()" />.</returns>
|
||||||
public static Task WaitOneAsync(this WaitHandle handle)
|
public static Task WaitOneAsync(this WaitHandle handle)
|
||||||
{
|
{
|
||||||
return new(() => handle.WaitOne());
|
if (handle is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(handle));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Task(() => handle.WaitOne());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue