private void TraceSpyButton1_Click(object sender, RoutedEventArgs e) { System.Windows.Controls.Primitives.ToggleButton tButton = sender as System.Windows.Controls.Primitives.ToggleButton; if (tButton.IsChecked ?? false) { tButton.Content = "Stop"; startTrace(); } else { tButton.Content = "Start"; if (TSpy == null) { TSpy = new Tracers.TraceSpy(TraceSpyListView); } TSpy.Enabled = false; } ToggleBStyle(tButton); }
private void startTrace() { if (TraceSpyListView != null) { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { TSpy = new Tracers.TraceSpy(TraceSpyListView); TSpy.FilterPID = pid; TraceSpyListView.ItemsSource = TSpy.Queue; ((System.Collections.Specialized.INotifyCollectionChanged)TraceSpyListView.ItemsSource).CollectionChanged -= new System.Collections.Specialized.NotifyCollectionChangedEventHandler(ListViewCollectionChanged); ((System.Collections.Specialized.INotifyCollectionChanged)TraceSpyListView.ItemsSource).CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(ListViewCollectionChanged); TSpy.StartReaderTask(); } )); } }