private async Task RefreshProcessListAsync(bool keepSelectedProcess) { if (ProcessListViewModel?.Processes == null) { return; } ProcessListViewModel.PerformanceCounterViewModel?.Dispose(); var selectedProcess = ProcessListViewModel.SelectedProcess; var filter = ProcessListViewModel.CollectionView?.Filter; var loadProcessTask = ProcessListViewModel?.LoadProcessesAsync(); var refreshInstanceTask = Task.Run(() => PerformanceCounterUtil.RefreshInstances()); await loadProcessTask; if (filter != null) { ProcessListViewModel.CollectionView.Filter = filter; } if (keepSelectedProcess) { ProcessListViewModel.Select(selectedProcess?.ProcessId); } await refreshInstanceTask; }
private void OnFind(WindowInfo windowInfo) { if (windowInfo.HWnd != IntPtr.Zero) { NativeMethods.GetWindowThreadProcessId(windowInfo.HWnd, out int processId); ProcessListViewModel.Select(processId); } }
public MainWindowViewModel(ProcessListViewModel processListViewModel) { ProcessListViewModel = processListViewModel; RefreshProcessListCommand = new DelegateCommand(OnRefreshProcessList); CompactMemoryCommand = new DelegateCommand(OnCompactMemory); CustomizeCommand = new DelegateCommand(OnCustomize); MouseDownCommand = new DelegateCommand(OnMouseDown); OnFindAction = new Action <WindowInfo>(OnFind); }