private void Analyze(DumpFileInfo dumpFileInfo) { int maxRetryCount = 5; int retryCount = 0; TimeSpan pauseBetweenAttempts = TimeSpan.FromSeconds(5); bool success = false; while (retryCount < maxRetryCount && !success) { try { Logger.PrintTrace($"Attempt {++retryCount}"); _defaultAnalysis.DumpFiles.Clear(); _defaultAnalysis.AddDumpFile(dumpFileInfo.FilePath); _defaultAnalysis.ReportPath = dumpFileInfo.FilePath + ".mht"; _defaultAnalysis.Symbols = DumpAnalyzerConfig.PublicSymbols; if (!string.IsNullOrEmpty(DumpAnalyzerConfig.RelativeSymbolsDirectory)) { _defaultAnalysis.Symbols += $";{GetRelativeSymbolsPath(dumpFileInfo)}"; } _dumpAnalyzer.RunAnalysis(_defaultAnalysis); success = true; } catch (FileLoadException ex) { Logger.ReportError($"error with reading the file {ex.FileName} - reetry again in {pauseBetweenAttempts}"); Logger.PrintError(ex); Thread.Sleep(pauseBetweenAttempts); } } }
private static string GetRelativeSymbolsPath(DumpFileInfo dumpFileInfo) { try { var version = ""; if (!string.IsNullOrEmpty(DumpAnalyzerConfig.VersionFile)) { version = File.ReadAllLines(DumpAnalyzerConfig.VersionFile).FirstOrDefault()?.Trim() ?? ""; } var relativeSymbolsDirectory = DumpAnalyzerConfig.RelativeSymbolsDirectory.ToLower().Replace("[version]", version); Logger.PrintTrace("relativeSymbol path is " + relativeSymbolsDirectory); return(Path.Combine(Path.GetDirectoryName(dumpFileInfo.FilePath), relativeSymbolsDirectory)); } catch (System.Exception ex) { Logger.PrintError(ex); } return(""); }