Refactored ListenerAsyncResult.cs
This commit is contained in:
parent
713c258989
commit
af250750b7
@ -105,6 +105,31 @@ namespace WebSocketSharp.Net
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Private Methods
|
||||||
|
|
||||||
|
private static void complete (ListenerAsyncResult asyncResult)
|
||||||
|
{
|
||||||
|
asyncResult._completed = true;
|
||||||
|
|
||||||
|
var waitHandle = asyncResult._waitHandle;
|
||||||
|
if (waitHandle != null)
|
||||||
|
waitHandle.Set ();
|
||||||
|
|
||||||
|
var callback = asyncResult._callback;
|
||||||
|
if (callback != null)
|
||||||
|
ThreadPool.UnsafeQueueUserWorkItem (
|
||||||
|
state => {
|
||||||
|
try {
|
||||||
|
callback (asyncResult);
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
}
|
||||||
|
},
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Internal Methods
|
#region Internal Methods
|
||||||
|
|
||||||
internal void Complete (Exception exception)
|
internal void Complete (Exception exception)
|
||||||
@ -113,22 +138,8 @@ namespace WebSocketSharp.Net
|
|||||||
? new HttpListenerException (500, "Listener closed.")
|
? new HttpListenerException (500, "Listener closed.")
|
||||||
: exception;
|
: exception;
|
||||||
|
|
||||||
lock (_sync) {
|
lock (_sync)
|
||||||
_completed = true;
|
complete (this);
|
||||||
if (_waitHandle != null)
|
|
||||||
_waitHandle.Set ();
|
|
||||||
|
|
||||||
if (_callback != null)
|
|
||||||
ThreadPool.UnsafeQueueUserWorkItem (
|
|
||||||
state => {
|
|
||||||
try {
|
|
||||||
_callback (this);
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
}
|
|
||||||
},
|
|
||||||
null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void Complete (HttpListenerContext context)
|
internal void Complete (HttpListenerContext context)
|
||||||
@ -169,22 +180,8 @@ namespace WebSocketSharp.Net
|
|||||||
_context = context;
|
_context = context;
|
||||||
_syncCompleted = syncCompleted;
|
_syncCompleted = syncCompleted;
|
||||||
|
|
||||||
lock (_sync) {
|
lock (_sync)
|
||||||
_completed = true;
|
complete (this);
|
||||||
if (_waitHandle != null)
|
|
||||||
_waitHandle.Set ();
|
|
||||||
|
|
||||||
if (_callback != null)
|
|
||||||
ThreadPool.UnsafeQueueUserWorkItem (
|
|
||||||
state => {
|
|
||||||
try {
|
|
||||||
_callback (this);
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
}
|
|
||||||
},
|
|
||||||
null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal HttpListenerContext GetContext ()
|
internal HttpListenerContext GetContext ()
|
||||||
|
Loading…
Reference in New Issue
Block a user