假设我有一个 F# 计算要在 C# 中处理,我想让它们同步运行。引擎盖下面有什么区别:
public static T RunSync<T>(FSharpAsync<T> computation)
{
return FSharpAsync.RunSynchronously(computation,
timeout: FSharpOption<int>.None,
cancellationToken: FSharpOption<System.Threading.CancellationToken>.None
);
}
或者
public static T RunSync<T>(FSharpAsync<T> computation)
{
return FSharpAsync.StartAsTask(computation,
taskCreationOptions: FSharpOption<TaskCreationOptions>.None,
cancellationToken: FSharpOption<System.Threading.CancellationToken>.None
).Result;
}
抱歉,如果这似乎是一个简单的问题,我对异步编程很陌生!