示例#1
0
        private static void ExecuteRecurrentRequests
        (
            Uri requestUri,
            HttpMethod requestMethod,
            DateTimeOffset testStart,
            DateTimeOffset testEnd,
            int threadCount,
            IEnumerable <KeyValuePair <string, string> > requestHeaders = null,
            int?expectedStatus = null
        )
        {
            var commandColl = new LoadTestRecurrentHttpRequest[threadCount];
            var taskColl    = new Task[threadCount];

            try
            {
                for (var i = 0; i < threadCount; i++)
                {
                    var httpRequest = new LoadTestHttpRequest()
                    {
                        RequestBody   = null,
                        RequestMethod = requestMethod,
                        RequestUri    = requestUri,
                    };

                    httpRequest.SetRequestHeaders(requestHeaders);

                    commandColl[i] = LoadTestRecurrentHttpRequest.Create
                                     (
                        httpRequest,
                        testStart,
                        testEnd,
                        expectedStatus,
                        GetBodyContent
                                     );

                    taskColl[i] = commandColl[i].ExecuteAsync();
                }

                Task.WaitAll(taskColl);
                LoadTestRecurrentHttpRequest.ResetInstanceCount();
            }
            finally
            {
                foreach (var command in commandColl)
                {
                    command.HttpRequest.Dispose();
                }
            }
        }