查看ReactiveUI
ReactiveCommands
的许多示例,代码类似于
Delete = ReactiveCommand.CreateAsyncObservable(x => DeleteImpl());
Delete.IsExecuting.ToProperty(this, x => x.IsDeleting, out _isDeleting);
Delete.ThrownExceptions.Subscribe(ex => this.Log().ErrorException("Something went wrong", ex));
我正在尝试使用CreateAsyncTask
代替CreateAsyncObservable
Delete = ReactiveCommand.CreateAsyncTask(x => DeleteImpl());
Delete.IsExecuting.ToProperty(this, x => x.IsDeleting, out _isDeleting);
Delete.ThrownExceptions.Subscribe(ex => this.Log().ErrorException("Something went wrong", ex));
Delete command
绑定到WPF按钮。
使用CreateAsyncObservable
,从错误恢复后启用该按钮。
使用CreateAsyncTask
,该按钮被禁用。
除了使用CreateAsyncObservable
(逻辑已经写成异步方法)之后,如何在错误后重新启用按钮?
答案 0 :(得分:0)
我正在使用的被叫方法签名导致了这个问题。
private Task<Unit> DeleteImpl()
{
throw new NotImplementedException();
}
缺少async
关键字
将方法更改为
private async Task<Unit> DeleteImpl()
{
throw new NotImplementedException();
}