Example #1
0
        internal TrapForThrottlingSimpleWait(string name, int requestQuota, RequestQuoteTimePeriodType requestQuoteTimePeriodType)
            : base(name)
        {
            _LastRequest = DateTime.Now;

            switch (requestQuoteTimePeriodType)
            {
            case RequestQuoteTimePeriodType.PerMinute:
                _RunWithIntervalInSeconds = new TimeSpan((long)(((60 * 10e6) / requestQuota)));
                break;

            case RequestQuoteTimePeriodType.PerSecond:
                _RunWithIntervalInSeconds = new TimeSpan((long)((10e6 / requestQuota)));
                break;

            default:
                throw new NotImplementedException();
            }
        }
        public static ITrapForThrottling CreateSimpleWait(string name, int requestQuota, RequestQuoteTimePeriodType requestQuoteTimePeriodType)
        {
            WriteToLog(string.Format("TrapForThrottling::CreateSimpleWait ({0})", name), WriteLogType.Info);
            var item = new TrapForThrottlingSimpleWait(name, requestQuota, requestQuoteTimePeriodType);

            return(AddItemToStorage(item));
        }