Table of contents
TOC
Collapse the table of content
Expand the table of content

AsyncBuilder.TryFinally<'T> Method (F#)

Den Delimarsky|Last Updated: 8/18/2017
|
1 Contributor

Implements try...finally in asynchronous computations.

Namespace/Module Path: Microsoft.FSharp.Control

Assembly: FSharp.Core (in FSharp.Core.dll)

Syntax

// Signature:
member this.TryFinally : Async<'T> * (unit -> unit) -> Async<'T>

// Usage:
asyncBuilder.TryFinally (computation, compensation)

Parameters

computation Type: Async<'T>

The input computation.

compensation Type: unit->unit

The action to be run after computation completes or raises an exception (including cancellation).

Return Value

An asynchronous computation that executes computation and compensation aftewards or when an exception is raised.

Remarks

Creates an asynchronous computation that runs computation. The action compensation is executed after computation completes, whether computation exits normally or by an exception. If compensation raises an exception itself the original exception is discarded and the new exception becomes the overall result of the computation.

A cancellation check is performed when the computation is executed. The existence of this method permits the use of try...finally in the async { ... } computation expression syntax.

Platforms

Windows 8, Windows 7, Windows Server 2012, Windows Server 2008 R2

Version Information

F# Core Library Versions

Supported in: 2.0, 4.0, Portable

See Also

Control.AsyncBuilder Class (F#)

Microsoft.FSharp.Control Namespace (F#)

© 2018 Microsoft