【问题标题】:Dispatcher.InvokeAsync in F#F# 中的 Dispatcher.InvokeAsync
【发布时间】:2015-09-17 05:59:51
【问题描述】:

我不明白如何将这段代码翻译成 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>

怎么做?

【问题讨论】:

  • InvokeAsync的类型是什么?

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


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2021-09-04
    • 1970-01-01
    • 2018-06-30
    • 2023-03-15
    • 1970-01-01
    • 2015-07-05
    • 2015-01-26
    • 1970-01-01
    • 2011-07-24
    相关资源
    最近更新 更多