public async Task <IEnumerable <PushResponse> > MakeStaggeredRequests(IRunSpecification runSpec, int requestCount,
                                                                              int requestGrouping, CancellationToken token)
        {
            var delayTasks = new List <Task <PushResponse> >();

            for (var count = 0; count < requestCount; count++)
            {
                var delay = random.Next(1, 1000);
                delayTasks.Add(GetDelayedAsync(runSpec.GenerateRelativeUrl(), "GET", null, delay, count,
                                               CancellationToken.None));
            }

            return(await Task.WhenAll(delayTasks).ConfigureAwait(false));
        }
Esempio n. 2
0
        public async Task <IEnumerable <PushResponse> > MakeStaggeredRequests(
            IRunSpecification runSpec,
            int requestCount,
            int requestGrouping,
            CancellationToken token)
        {
            // Fire off request tasks with staggered delay of 1-999 milliseconds
            var requestTasks = Enumerable.Range(1, requestCount)
                               .Select(i => GetDelayedAsync(
                                           runSpec.GenerateRelativeUrl(), runSpec.Verb, runSpec.Content, random.Next(1, 1000), requestGrouping,
                                           token))
                               .ToList();

            return(await Task.WhenAll(requestTasks)
                   .ConfigureAwait(continueOnCapturedContext: false));
        }