public void RunScan(ApplicationProfile app, string scan_id, string modules, Action <string, string> ScanMethod, BuildStatusType running, BuildStatusType failure) { var stopWatch = new Stopwatch(); TimeSpan ts; string elapsedTime; stopWatch.Start(); ScanMethod(app.id, modules); var scanStatus = running; while (scanStatus == running) { ts = stopWatch.Elapsed; elapsedTime = string.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10); _logger.LogInformation($"Scan {scan_id} is still running and has been running for {elapsedTime}."); Thread.Sleep(20000); scanStatus = _veracodeService.GetScanStatus(app.id, $"{scan_id}"); } ts = stopWatch.Elapsed; elapsedTime = string.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10); stopWatch.Stop(); if (scanStatus == failure) { throw new Exception("Scan status returned an error status."); } _logger.LogInformation($"Scan complete for {scan_id} and took {elapsedTime}."); }