我无法理解如何将此代码翻译为f#:
var x = await Application.Current.Dispatcher.InvokeAsync(c);
// the type of c is Func<int>
如果我尝试这样做
let x = Async.AwaitTask(Application.Current.Dispatcher.InvokeAsync(c))
我遇到编译错误:
Threading.DispatcherOperation<int> is not compatible with Task<int>
怎么做?
答案 0 :(得分:2)
我可以看到DispatcherOperation是等待的,F#编译器不支持直接使用它们。尝试使用DispatcherOperation.Task
作为Async.AwaitTask