示例#1
0
        private void Worker()
        {
            WaitHandle[] wait = { _readyEvent.WaitHandle, StopEvent.WaitHandle };

            while (0 == WaitHandle.WaitAny(wait))
            {
                try
                {
                    HttpListenerContext context;
                    if (!_queue.TryDequeue(out context))
                    {
                        _readyEvent.Reset();
                        continue;
                    }
                    if (!SecurityOn || SecMan.HandleRequest(context.Request))
                    {
                        Process(context);
                    }
                }
                catch (Exception ex)
                {
                    if (ThrowExceptions)
                    {
                        throw;
                    }
                    Logger.Log(ex);
                }
            }
        }
示例#2
0
 protected override void ProcessContext(HttpListenerContext context)
 {
     Task.Run(() =>
     {
         if (!SecurityOn || SecMan.HandleRequest(context.Request))
         {
             Process(context);
         }
     });
 }