Beispiel #1
0
        public HttpWebResponse Execute(HttpWebRequest request)
        {
            RequestLimiter requestLimiter = GetRequestLimiter(request);

            //Blocks thread until another request is allowed
            requestLimiter.WaitForAllowing();
            return((HttpWebResponse)request.GetResponse());
        }
Beispiel #2
0
        public HttpWebResponse ExecuteWithMaxReqPerSecond(HttpWebRequest request, uint maxReqPerSecond)
        {
            if (maxReqPerSecond == 0)
            {
                throw new ArgumentException();
            }

            RequestLimiter requestLimiter = GetRequestLimiter(request);

            //Blocks thread until another request is allowed
            requestLimiter.WaitForAllowing(maxReqPerSecond);
            return(this.Execute(request));
        }