static void Main(string[] args) { int type = 0; Console.WriteLine("Select type of test: 1) Wizard; 2) Resend; 3)ESignature"); Int32.TryParse(Console.ReadLine(), out type); switch (type) { case 1: { int count = 0; Console.WriteLine("Enter the number of tests examples: "); Int32.TryParse(Console.ReadLine(), out count); Console.WriteLine("The number is: " + count); var testManager = new LoadTestManager(count); testManager.RunTestsInThreads(); break; }; case 2: { var testManager = new LoadTestManager(0); testManager.RunResendTest(); break; } case 3: { int count = 0; Console.WriteLine("Enter the number of tests examples(50 max): "); Int32.TryParse(Console.ReadLine(), out count); if (count > 50) { count = 50; } Console.WriteLine("The number is: " + count); var testManager = new LoadTestManager(0); testManager.RunESignatureTest(count); break; } default: { Console.WriteLine("Incorrect input;"); break; } } Console.ReadLine(); }
async Task StartLoadTestAsync(int numThreads, int numTimesPerThread, CancellationToken ct) { LogActivity($"Setting up {numThreads} test threads."); var loadTestThreadDatas = SetupLoadTestThreadList(numThreads, numTimesPerThread); // This query when executed will return a collection of tasks. var loadTestThreadsQuery = from loadTestThreadData in loadTestThreadDatas select LoadTestManager.RunThreadLoadTestsActuallyLoggingAsync(txtGuaranteedDeliveryEndpoint.Text, txtNetworkJsonEndpoint.Text, loadTestThreadData, ct); LogActivity("Loading new threads."); // ToList executes the query and start the tasks. List <Task <LoadTestThreadResults> > loadTestThreads = loadTestThreadsQuery.ToList(); LogActivity("Waiting for thread completions."); while (loadTestThreads.Count > 0) { // Identify the first task that completes. Task <LoadTestThreadResults> nextFinishedThread = await Task.WhenAny(loadTestThreads); // Remove the selected task from the list so that you don't process it more than once. loadTestThreads.Remove(nextFinishedThread); // Await the completed task. var loadTestThreadResults = await nextFinishedThread; AddThreadResultsToGrid(loadTestThreadResults); } }
public static async Task MainAsync() { var testManager = new LoadTestManager(3); await testManager.RunTestsAsync(); }