public HttpListenerAcceptor(IPEndPoint bindTo, Uri uri, IHttpListenerRequestHandler handler)
 {
     listener.Prefixes.Add(EnsureTrailingSlash(FormatPrefix(bindTo, uri)));
     contexts = new HttpListenerAcceptorContext[1];
     this.handler = handler;
     for (int i = 0; i != contexts.Length; ++i)
         contexts[i] = new HttpListenerAcceptorContext(this, i);
 }
 bool BeginGetContext(HttpListenerAcceptorContext context)
 {
     if(isStopping)
         return false;
     backlog[context.Offset] = listener.BeginGetContext(BeginRequest, context).AsyncWaitHandle;
     return true;
 }
 void Dispatch(HttpListenerAcceptorContext context, IAsyncResult asyncResult)
 {
     if(BeginGetContext(context))
         handler.Process(listener.EndGetContext(asyncResult));
 }