F#

时间:2015-09-16 21:14:14

标签: wpf f# task-parallel-library dispatcher

我无法理解如何将此代码翻译为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>

怎么做?

1 个答案:

答案 0 :(得分:2)

我可以看到DispatcherOperation是等待的,F#编译器不支持直接使用它们。尝试使用DispatcherOperation.Task作为Async.AwaitTask

的参数
相关问题