我有以下代码。
现在函数
let rec consume() : Async<unit> = async {
.....
listA
|> Seq.iter(fun i ->
.....
let listB : seq<...> option =
let c = getListB a b
match c with
| Some d -> Seq.filter(....) |> Some
| None -> None
match listB with .....
....
现在函数
getListB
已经转换为返回async<Seq<B>>
而不是Seq<B>
。所以代码被转换成以下形式。然而,getListB
会阻塞执行。如何将其重写为非阻塞方式?仅仅将该行代码转换为let! c = getListB a b
并不能解决问题,因为这段代码在内部lambda中。错误信息是“此结构只能在计算表达式中使用”。let rec consume() : Async<unit> = async {
.....
listA
|> Seq.iter(fun i ->
.....
let listB : seq<...> option =
let c = getListB a b |> Async.RunSynchronously
match c with
| Some d -> Seq.filter(....) |> Some
| None -> None