public void Execute(object parameter) { if (Interlocked.Exchange(ref _canExecute, 0) != 1) { return; } CanExecuteChanged.NullSafeInvoke(this, new EventArgs()); try { _action.Invoke(); } catch (Exception ex) { UiHelper.ShowError(null, ex); } Interlocked.Exchange(ref _canExecute, 1); CanExecuteChanged.NullSafeInvoke(this, new EventArgs()); }
private void ClearContent() { try { if (CheckAccess()) { _treeView.ItemsSource = null; _listView.ItemsSource = null; IsEnabled = false; } else { Dispatcher.Invoke(ClearContent); } } catch (Exception ex) { UiHelper.ShowError(this, ex); } }
private async Task RefreshContent(GameLocationInfo obj) { try { if (CheckAccess()) { _treeNodes = await obj.ArchivesTree; _treeView.ItemsSource = _treeNodes; SelectNode(); IsEnabled = true; } else { await Dispatcher.Invoke(async() => await RefreshContent(obj)); } } catch (Exception ex) { ClearContent(); UiHelper.ShowError(this, ex); } }
private string FormatValue(long value) { return(_units == UiProgressUnits.Items ? value.ToString(CultureInfo.CurrentCulture) : UiHelper.FormatBytes(value)); }