private void Callback(IAsyncResult ar) { Socket socket; try { socket = _listener.EndAcceptSocket(ar); } catch (ObjectDisposedException) { return; } _listener.BeginAcceptSocket(Callback, null); var instance = new Instance(socket, _app); instance.Run() .ContinueWith(t => { if (!t.IsFaulted) { return; } Trace.TraceError(t.Exception != null ? t.Exception.Message : "A bad thing happened."); instance.TryDispose(); }); }
private void Callback(IAsyncResult ar) { Socket socket; try { socket = _listener.EndAcceptSocket(ar); } catch (ObjectDisposedException) { return; } _listener.BeginAcceptSocket(Callback, null); var instance = new Instance(socket, _app); instance.Run() .ContinueWith(t => { if (!t.IsFaulted) return; Trace.TraceError(t.Exception != null ? t.Exception.Message : "A bad thing happened."); instance.TryDispose(); }); }