diff --git a/src/Microsoft.DotNet.XHarness.iOS.Shared/CrashSnapshotReporter.cs b/src/Microsoft.DotNet.XHarness.iOS.Shared/CrashSnapshotReporter.cs index dd3a0f380..956f474a5 100644 --- a/src/Microsoft.DotNet.XHarness.iOS.Shared/CrashSnapshotReporter.cs +++ b/src/Microsoft.DotNet.XHarness.iOS.Shared/CrashSnapshotReporter.cs @@ -85,8 +85,7 @@ public async Task EndCaptureAsync(TimeSpan timeout) } else { - - Thread.Sleep(TimeSpan.FromSeconds(1)); + await Task.Delay(TimeSpan.FromSeconds(1)); } continue; @@ -101,27 +100,30 @@ public async Task EndCaptureAsync(TimeSpan timeout) foreach (var path in newCrashFiles) { // It can happen that the crash log is still being written to so we have to retry - int retry = 0; + int retry = 1; while (true) { try { - _logs.AddFile(path, $"Crash report: {Path.GetFileName(path)}"); + var fileName = Path.GetFileName(path); + _log.WriteLine($" - Adding {path}"); + _logs.AddFile(path, $"Crash report: {fileName}"); + _log.WriteLine($" Successfully copied {fileName}"); break; } catch (Exception e) { - _log.WriteLine($"Failed to copy a crash report {path}: {e.Message}"); + _log.WriteLine($" Attempt {retry} to copy a crash report failed: {e.Message}"); } if (retry == 3) { - _log.WriteLine($"Failed to copy a crash report after {retry} retries, skipping {path}"); + _log.WriteLine($" Failed to copy a crash report after {retry} retries"); break; } ++retry; - Thread.Sleep(TimeSpan.FromSeconds(2 * retry)); + await Task.Delay(TimeSpan.FromSeconds(2 * retry)); } } }