我想在命令执行之前设置忙标志和状态栏文本,并在完成后重置标志和文本.我的工作代码在这里:
Cmd = ReactiveCommand.Create();
Cmd.Subscribe(async _ =>
{
IsBusy = true;
StatusBarText = "Doing job...";
try
{
var organization = await DoAsyncJob();
//do smth w results
}
finally
{
IsBusy = false;
StatusBarText = "Ready";
});
Run Code Online (Sandbox Code Playgroud)
是否有可能以"正确的方式"做到这一点?像这样:
Cmd = ReactiveCommand.CreateAsyncTask(_ => DoAsyncJob());
//how to do pre-action?
//is exists more beautiful way to to post-action?
Cmd.Subscribe(res =>
{
try
{
//do smth w results
}
finally
{
IsBusy = false;
StatusBarText = "Ready";
}
});
Run Code Online (Sandbox Code Playgroud)
或这个:
Cmd = ReactiveCommand.CreateAsyncTask(_ => DoAsyncJob()); …Run Code Online (Sandbox Code Playgroud)