public IActionResult CancelTest() { int retries = 0; do { _loadTestRunner.CancelTest(); retries += 1; }while (_loadTestRunner.IsTestRunning() && retries < 5); if (retries >= 5) { throw new Exception("The performance and load tests were not cancelled after 5 retries!"); } return(Ok("The performance and load tests were canceled!")); }