-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Easy way to get result synchronously? #28
Comments
Nope. Even if the builder handled this case specially, you could await any sort of Task in your |
@rspeele this is to stop getting spurious compiler errors like this: [<EntryPoint>]
let main argv =
task {
return 0
}.Result which gives a compiler error: "This value is not a function and cannot be applied". The "fix" in this case is to either separate out the creation of the task and the I'd suggest adding something like |
You could create an type extension on top of Task quite easily to achieve the above: [<Extension>]
type Task() =
static member RunSynchronously(task:_ Task) = task.Result
[<EntryPoint>]
let main argv =
task {
return 0
} |> Task.RunSynchronously |
Sorry, I'm not in favor of it. Four reasons:
|
A place where you need the synchronous result often is in F# scripting code or at the REPL. Maybe a "universal" helper that awaits every kind of asynchronous operation for those scenario would be nice (thinking of the |
Is there an equivalent of
Async.RunSynchronously
aside from the.Result
? I'm thinking as a function that the task can be piped to.The text was updated successfully, but these errors were encountered: