async Task <bool> AddGeometry(string text) { Logger.Log(this, string.Format("AddGeometry: {0}", text)); // first call to method if (this.dte == null) { Logger.Log(this, string.Format("First call to AddGeometry.")); this.dte = FirstToolWindowPackage.WindowToolPackage.GetService(); Logger.Log(this, string.Format("Created DTE object.")); if (cb_UpdateOnContextChange.IsChecked.Value) { dte.Events.DebuggerEvents.OnContextChanged += DebuggerEvents_OnContextChanged; Logger.Log(this, string.Format("Added DebuggerEvents_OnContextChanged event.")); } } // Ensure that debugger is running if (dte.Debugger.CurrentStackFrame == null) { MessageBox.Show("You need to have the Debugger running"); return(false); } EnvDTE.Expression local = dte.Debugger.GetExpression(text, true, 1); if (local == null) { Logger.Log(this, string.Format("dte.Debugger.GetExpression for variable \"{0}\" return null", local.Name)); return(false); } Logger.Log(this, string.Format("name: {0}, val: {1}, type: {2}", local.Name, local.Value, local.Type)); // since there is a check for ennumerable that creates a new variable, // we don't want to update the viz for that dte.Events.DebuggerEvents.OnContextChanged -= DebuggerEvents_OnContextChanged; if (ReaderUtils.TryAddObject(local, hv, _dict)) { Logger.Log(this, string.Format("All good")); } else { Logger.Log(this, string.Format("No good")); } // we reattach the OnContextChanged if (cb_UpdateOnContextChange.IsChecked.Value) { dte.Events.DebuggerEvents.OnContextChanged += DebuggerEvents_OnContextChanged; } return(true); }