ofTaskAction

Namespace: FsToolkit.ErrorHandling

Transforms a Task into an Async<Result<unit, 'Error>>.

Function Signature

Task -> Async<Result<unit, 'Error>>

Examples

Example 1

let result = AsyncResult.ofTaskAction (Task.Delay 1000)
// async { do () }

Example 2

let result = AsyncResult.ofTaskAction (Task.FromException (System.Exception("Boom!")))
// async { return Error (System.Exception("Boom!")) }

Last updated