/// <summary> /// If there is a pending connection, the request is parsed an /// scheduled to be executed in the kernel. /// </summary> public void SchedulePending() { while (_server.Pending()) { new RequestTask() { Handler = Handler, Context = LPWebContext.FromSocket(_server.AcceptSocket()) }.ScheduleTask(); } }
/// <summary> /// Thread that listens to new requests and starts off tasks /// to send the requests to the OnRequest event. /// </summary> private void WebServerThread() { // from http://www.codeproject.com/Articles/1505/Create-your-own-Web-Server-using-C try { IsListening = true; while (_server != null) { var socket = _server.AcceptSocket(); Task.Factory.StartNew(() => { var ctx = LPWebContext.FromSocket(socket); try { if (OnRequest != null) { OnRequest(this, ctx); } } finally { ctx.Finish(); } }); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { IsListening = false; } }