public static void EnqueueForEach <T>(this Process process, Dispatcher dispatcher, IList <T> items, Action <T> work) { DebuggeeState debuggeeStateWhenEnqueued = process.DebuggeeState; dispatcher.BeginInvoke( DispatcherPriority.Normal, (Action) delegate { ProcessItems(process, dispatcher, 0, items, work, debuggeeStateWhenEnqueued); } ); }
/// <param name="process">Process on which to track debuggee state</param> 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(); } }
Value GetFromCache(StackFrame context) { if (expressionCache == null || expressionCache_debuggerState != context.Process.DebuggeeState || expressionCache_thread != context.Thread) { expressionCache = new Dictionary <Expression, Value>(); expressionCache_debuggerState = context.Process.DebuggeeState; expressionCache_thread = context.Thread; context.Process.TraceMessage("Expression cache cleared"); } if (expressionCache.ContainsKey(this)) { Value cachedResult = expressionCache[this]; if (!cachedResult.IsInvalid) { return(cachedResult); } } return(null); }
/// <param name="process">Process on which to track debuggee state</param> public static void DoEvents(Process process) { if (process == null) { return; } DebuggeeState oldState = process.DebuggeeState; //using(new PrintTimes("Application.DoEvents()")) { Application.DoEvents(); } { } DebuggeeState newState = process.DebuggeeState; if (oldState != newState) { LoggingService.Info("Aborted because debuggee resumed"); throw new AbortedBecauseDebuggeeResumedException(); } }
static void ProcessItems <T>(Process process, Dispatcher dispatcher, int startIndex, IList <T> items, Action <T> work, DebuggeeState debuggeeStateWhenEnqueued) { var watch = new System.Diagnostics.Stopwatch(); watch.Start(); for (int i = startIndex; i < items.Count; i++) { int index = i; if (process.IsPaused && debuggeeStateWhenEnqueued == process.DebuggeeState) { try { // Do the work, this may recursively enqueue more work work(items[index]); } catch (System.Exception ex) { if (process == null || process.HasExited) { // Process unexpectedly exited - silently ignore } else { MessageService.ShowException(ex); } break; } } // if we are too slow move to background if (watch.ElapsedMilliseconds > 100) { dispatcher.BeginInvoke( DispatcherPriority.Background, (Action) delegate { ProcessItems(process, dispatcher, index, items, work, debuggeeStateWhenEnqueued); } ); break; } } }