// http://weblog.west-wind.com/posts/2005/Dec/04/Add-a-Web-Server-to-your-NET-20-app-with-a-few-lines-of-code protected void WebRequestCallback(IAsyncResult result) { // Get out the context object HttpListenerContext context = listener.EndGetContext(result); // *** Immediately set up the next context listener.BeginGetContext(new AsyncCallback(WebRequestCallback), listener); ContextWrapper contextWrapper = new ContextWrapper(context); // Create a local workflow instance associated with the workflow for this request. workflow.Execute(contextWrapper); }
protected void WaitForConnection(object objListener) { HttpListener listener = (HttpListener)objListener; while (true) { // Wait for a connection. Return to caller while we wait. HttpListenerContext context = listener.GetContext(); // Create a local workflow instance associated with the workflow for this request. workflow.Execute(context); } }