2度押し防止のための機能を追加しました。
名前はBusyNotifierです。
こんな感じで使います。
public class MainWindowViewModel { private BusyNotifier BusyNotifier { get; } = new BusyNotifier(); public ReactiveProperty<string> Output { get; } = new ReactiveProperty<string>(); public ReactiveCommand ExecuteCommand { get; } public MainWindowViewModel() { this.ExecuteCommand = this.BusyNotifier .Select(x => !x) .ToReactiveCommand(); this.ExecuteCommand.Subscribe(async _ => { if (this.BusyNotifier.IsBusy) { return; } using (this.BusyNotifier.ProcessStart()) { var result = await this.HeavyTaskAsync(); this.Output.Value = result.ToString(); } }); } public async Task<DateTime> HeavyTaskAsync() { await Task.Delay(5000); return DateTime.Now; } }