[Modify] Polish it
This commit is contained in:
parent
ad5f5aeb0c
commit
7fa4cc4f0c
@ -722,17 +722,26 @@ namespace WebSocketSharp.Net
|
|||||||
public HttpListenerContext EndGetContext (IAsyncResult asyncResult)
|
public HttpListenerContext EndGetContext (IAsyncResult asyncResult)
|
||||||
{
|
{
|
||||||
CheckDisposed ();
|
CheckDisposed ();
|
||||||
|
|
||||||
if (asyncResult == null)
|
if (asyncResult == null)
|
||||||
throw new ArgumentNullException ("asyncResult");
|
throw new ArgumentNullException ("asyncResult");
|
||||||
|
|
||||||
var ares = asyncResult as HttpListenerAsyncResult;
|
var ares = asyncResult as HttpListenerAsyncResult;
|
||||||
if (ares == null)
|
|
||||||
throw new ArgumentException ("A wrong IAsyncResult.", "asyncResult");
|
|
||||||
|
|
||||||
if (ares.EndCalled)
|
if (ares == null) {
|
||||||
throw new InvalidOperationException ("This IAsyncResult cannot be reused.");
|
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;
|
ares.EndCalled = true;
|
||||||
|
|
||||||
if (!ares.IsCompleted)
|
if (!ares.IsCompleted)
|
||||||
ares.AsyncWaitHandle.WaitOne ();
|
ares.AsyncWaitHandle.WaitOne ();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user