Snippets tagged asynchronous programming

  • Implementing active objects with a MailboxProcessor

    Mailbox processors can easily be used to implement active objects. This example shows how to do that with a reusable wrapper type and minimal boilerplate code in the actual class definitions. Supports both asynchronous calls and synchronous calls. For the latter case, exceptions are automatically propagated back to the caller.

    92 people like this

    Posted: 13 years ago by Wolfgang Meyer

  • Async workflow with asynchronous "finally" clause

    The F# Core library offers async.TryFinally which where a synchronous compensation function (of type unit -> unit) is run after an error or cancellation. However, it offers no way to start an asynchronous compensation. The TryFinallyAsync method defined below offers a way around this.

    2 people like this

    Posted: 8 years ago by Anton Tcholakov

  • Posting async requests to an unreliable agent with error handling

    This example shows an implementation a MailboxProcessor<'T> extension method for posting messages and awaiting an asynchronous reply from a mailbox processor agent which mail fail. The error continuation is called if a failure event is triggered on the agent after the message is posted. The agent goes into a failed state where the result of all future messages posted with this mechanism is failure.

    2 people like this

    Posted: 9 years ago by Anton Tcholakov