// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; using System.Windows.Threading; using Debugger; namespace ILSpy.Debugger.Models.TreeModel { public static partial class Utils { /// Process on which to track debuggee state public static void DoEvents(Process process) { if (process == null) return; DebuggeeState oldState = process.DebuggeeState; WpfDoEvents(); DebuggeeState newState = process.DebuggeeState; if (oldState != newState) { //LoggingService.Info("Aborted because debuggee resumed"); throw new AbortedBecauseDebuggeeResumedException(); } } public static void WpfDoEvents() { DispatcherFrame frame = new DispatcherFrame(); Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => frame.Continue = false)); Dispatcher.PushFrame(frame); } } public class AbortedBecauseDebuggeeResumedException: System.Exception { public AbortedBecauseDebuggeeResumedException(): base() { } } public class PrintTimes: PrintTime { public PrintTimes(string text): base(text + " - end") { //LoggingService.InfoFormatted("{0} - start", text); } } public class PrintTime: IDisposable { string text; System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); public PrintTime(string text) { this.text = text; stopwatch.Start(); } public void Dispose() { stopwatch.Stop(); //LoggingService.InfoFormatted("{0} ({1} ms)", text, stopwatch.ElapsedMilliseconds); } } }