wasSharpNET

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 22  →  ?path2? @ 21
/Network/HTTP/HTTPServer.cs
@@ -25,7 +25,6 @@
public bool IsRunning => HTTPListener != null && HTTPListener.IsListening;
 
private readonly ManualResetEventSlim stopListen = new ManualResetEventSlim(false);
private readonly ManualResetEventSlim listenStop = new ManualResetEventSlim(false);
 
public bool Start(List<string> prefixes)
{
@@ -47,10 +46,9 @@
return ThreadPool.QueueUserWorkItem(Listen, new HTTPServerCallbackState(HTTPListener));
}
 
public bool Stop(int timeout)
public void Stop()
{
stopListen.Set();
return listenStop.Wait(timeout);
}
 
private void Listen(object state)
@@ -59,20 +57,12 @@
 
while (callbackState.Listener.IsListening)
{
callbackState.Listener?.BeginGetContext(ContextCallback, callbackState);
callbackState.Listener.BeginGetContext(ContextCallback, callbackState);
 
if (WaitHandle.WaitAny(new[] { callbackState.ContextRetrieved, stopListen.WaitHandle }) != 1)
continue;
 
try
{
callbackState.Listener.Stop();
callbackState.Listener.Close();
}
finally
{
listenStop.Set();
}
callbackState.Listener.Stop();
break;
}
}
@@ -113,7 +103,7 @@
 
public void Dispose()
{
stopListen.Set();
Stop();
}
 
private class HTTPServerCallbackState