public static IEnumerator<object> MainTask() { while (!Settings.DebuggingToolsInstalled) { // TODO: Add support for using the x64 debugging tools var defaultPath = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"Microsoft SDKs\Windows\v7.1" ); if (!Directory.Exists(defaultPath)) defaultPath = defaultPath.Replace(" (x86)", ""); bool isSdkInstalled = Directory.Exists(defaultPath); defaultPath = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"Microsoft SDKs\Windows\v7.1\Redist\Debugging Tools for Windows\dbg_x86.msi" ); if (!File.Exists(defaultPath)) defaultPath = defaultPath.Replace(" (x86)", ""); bool areRedistsInstalled = File.Exists(defaultPath); if (areRedistsInstalled) { var result = MessageBox.Show("The x86 Debugging Tools for Windows from SDK 7.1 are not installed. Would you like to install them now?", "Error", MessageBoxButtons.YesNo); if (result == DialogResult.No) { Application.Exit(); yield break; } yield return RunProcess(new ProcessStartInfo( "msiexec.exe", String.Format("/package \"{0}\"", defaultPath) )); } else if (isSdkInstalled) { MessageBox.Show("The x86 Debugging Tools for Windows from SDK 7.1 are not installed, and you did not install the redistributables when you installed the SDK. Please either install the debugging tools or the redistributables.", "Error"); Application.Exit(); yield break; } else { var result = MessageBox.Show("Windows SDK 7.1 is not installed. Would you like to download the SDK?", "Error", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) Process.Start("https://www.microsoft.com/en-us/download/details.aspx?id=8279"); Application.Exit(); yield break; } yield return new Sleep(1.0); } var args = Environment.GetCommandLineArgs().Skip(1); if (args.Count() > 0) { yield return OpenFilenames(args); Application.Exit(); } else { using (var window = new MainWindow(Scheduler)) yield return window.Show(); Application.Exit(); } }
public static IEnumerator<object> OpenFilenames(IEnumerable<string> filenames, MainWindow mainWindow = null) { var diffs = new HashSet<string>(); var snapshots = new HashSet<string>(); string recording = null; foreach (var filename in filenames) { switch (Path.GetExtension(filename)) { case ".heaprecording": { if (recording != null) { MessageBox.Show("Only one heap recording can be opened at a time.", "Error"); continue; } else if (snapshots.Count > 0) { MessageBox.Show("You cannot open snapshots and a recording in the same session.", "Error"); continue; } recording = filename; } break; case ".heapsnap": { if (recording != null) { MessageBox.Show("You cannot open snapshots and a recording in the same session.", "Error"); continue; } snapshots.Add(filename); } break; case ".heapdiff": { diffs.Add(filename); } break; } } var futures = new OwnedFutureSet(); var disposables = new HashSet<IDisposable>(); if ((recording != null) || (snapshots.Count > 0)) { if (mainWindow == null) { mainWindow = new MainWindow(Scheduler); disposables.Add(mainWindow); futures.Add(mainWindow.Show()); } if (recording != null) mainWindow.OpenRecording(recording); else mainWindow.OpenSnapshots(snapshots); } foreach (var diff in diffs) { var viewer = new DiffViewer(Scheduler); disposables.Add(viewer); if (mainWindow != null) futures.Add(viewer.Show(mainWindow)); else futures.Add(viewer.Show()); yield return viewer.LoadDiff(diff); } if (futures.Count == 0) { if ((mainWindow == null) && (disposables.Count > 0)) throw new InvalidDataException(); } else { using (futures) try { yield return Future.WaitForAll(futures); } finally { foreach (var disposable in disposables) disposable.Dispose(); } } }