Ejemplo n.º 1
0
 public void Enqueue(string url, string body, Action <int, string> callback, Plugin owner, RequestMethod method = 1, Dictionary <string, string> headers = null, float timeout = 0f)
 {
     WebRequests.WebRequest webRequest = new WebRequests.WebRequest(url, callback, owner)
     {
         Method         = method.ToString(),
         RequestHeaders = headers,
         Timeout        = timeout,
         Body           = body
     };
     lock (this.syncroot)
     {
         this.queue.Enqueue(webRequest);
     }
     this.workevent.Set();
 }
Ejemplo n.º 2
0
        private void Worker()
        {
            int num;
            int num1;

            try
            {
                while (!this.shutdown)
                {
                    ThreadPool.GetAvailableThreads(out num, out num1);
                    if (num <= this.maxWorkerThreads || num1 <= this.maxCompletionPortThreads)
                    {
                        Thread.Sleep(100);
                    }
                    else
                    {
                        WebRequests.WebRequest webRequest = null;
                        lock (this.syncroot)
                        {
                            if (this.queue.Count > 0)
                            {
                                webRequest = this.queue.Dequeue();
                            }
                        }
                        if (webRequest == null)
                        {
                            this.workevent.WaitOne();
                        }
                        else
                        {
                            webRequest.Start();
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Interface.Oxide.LogException("WebRequests worker: ", exception);
            }
        }