From 7fa4cc4f0c5faa3ff3dde3bf8c1946ca6e80a518 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 29 Mar 2021 17:41:37 +0900 Subject: [PATCH] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index c7207250..918b6ed0 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -722,17 +722,26 @@ namespace WebSocketSharp.Net public HttpListenerContext EndGetContext (IAsyncResult asyncResult) { CheckDisposed (); + if (asyncResult == null) throw new ArgumentNullException ("asyncResult"); var ares = asyncResult as HttpListenerAsyncResult; - if (ares == null) - throw new ArgumentException ("A wrong IAsyncResult.", "asyncResult"); - if (ares.EndCalled) - throw new InvalidOperationException ("This IAsyncResult cannot be reused."); + if (ares == null) { + var msg = "A wrong IAsyncResult instance."; + + throw new ArgumentException (msg, "asyncResult"); + } + + if (ares.EndCalled) { + var msg = "This IAsyncResult instance cannot be reused."; + + throw new InvalidOperationException (msg); + } ares.EndCalled = true; + if (!ares.IsCompleted) ares.AsyncWaitHandle.WaitOne ();