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()); }