From 4828300076d72146203d8a76a519931e8f846b2d Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Sun, 27 Jun 2021 13:06:17 +0100 Subject: [PATCH] (#42) Validate not-null handle --- X10D/src/WaitHandleExtensions/WaitHandleExtensions.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/X10D/src/WaitHandleExtensions/WaitHandleExtensions.cs b/X10D/src/WaitHandleExtensions/WaitHandleExtensions.cs index c075e31..97fbff1 100644 --- a/X10D/src/WaitHandleExtensions/WaitHandleExtensions.cs +++ b/X10D/src/WaitHandleExtensions/WaitHandleExtensions.cs @@ -1,4 +1,5 @@ -using System.Threading; +using System; +using System.Threading; using System.Threading.Tasks; namespace X10D @@ -15,7 +16,12 @@ namespace X10D /// A task which encapsulates . 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()); } } }