Exemplo n.º 1
0
        async Task RunQueries(string[] servers, CancellationToken token, int maxParallel)
        {
            completedCases = 0;
            UpdateDataGridViewResultsInvoke();
            UpdateProgressInvoke(completedCases, requestsCases.Count);

            try
            {
                var coldTasks = new List <Task>(requestsCases.Count);
                foreach (var requstCase in requestsCases)
                {
                    coldTasks.Add(new Task(async() => await RequestParallelManager.SendRequestsParallelAsync(requstCase, servers, token)));
                }

                await ThreadManager.Run(coldTasks, maxParallel, caseCallback, token);
            }
            catch (TaskCanceledException)
            {
            }
        }
        public async Task TestMethod1Async()
        {
            var testCase = new RequestCase(
                new Request
            {
                requestType = RequestType.GET,
                path        = @"/search",
                parameters  = new Dictionary <string, string>()
                {
                    { "q", "42" }
                }
            }
                );

            await RequestParallelManager.SendRequestsParallelAsync(
                testCase,
                new string[] { "https://www.google.com", "http://www.google.com" },
                CancellationToken.None);

            Assert.AreEqual(testCase._status, CaseStatus.Equals);
        }