(#42) Validate not-null handle

This commit is contained in:
Oliver Booth 2021-06-27 13:06:17 +01:00
parent 49ed44100d
commit 4828300076
1 changed files with 8 additions and 2 deletions

View File

@ -1,4 +1,5 @@
using System.Threading;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace X10D
@ -15,7 +16,12 @@ namespace X10D
/// <returns>A task which encapsulates <see cref="WaitHandle.WaitOne()" />.</returns>
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());
}
}
}