Bagikan melalui


Async.FromBeginEnd<'Arg1,'Arg2,'Arg3,'T> Method (F#)

Creates an asynchronous computation in terms of a Begin/End pair of actions in the style used in CLI APIs.

Namespace/Module Path: Microsoft.FSharp.Control

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

// Signature:
static member FromBeginEnd : 'Arg1 * 'Arg2 * 'Arg3 * ('Arg1 * 'Arg2 * 'Arg3 * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * ?(unit -> unit) -> Async<'T>

// Usage:
Async.FromBeginEnd (arg1, arg2, arg3, beginAction, endAction)
Async.FromBeginEnd (arg1, arg2, arg3, beginAction, endAction, cancelAction = cancelAction)

Parameters

  • arg1
    Type: 'Arg1

    The first argument for the operation.

  • arg2
    Type: 'Arg2

    The second argument for the operation.

  • arg3
    Type: 'Arg3

    The third argument for the operation.

  • beginAction
    Type: 'Arg1 * 'Arg2 * 'Arg3 * AsyncCallback * obj -> IAsyncResult

    The function initiating a traditional CLI asynchronous operation.

  • endAction
    Type: IAsyncResult -> 'T

    The function completing a traditional CLI asynchronous operation.

  • cancelAction
    Type: (unit -> unit)

    An optional function to be executed when a cancellation is requested.

Return Value

An asynchronous computation wrapping the given Begin/End functions.

Remarks

This overload should be used if the operation is qualified by three arguments. For example, the following code creates an asynchronous computation for a web service call.

Async.FromBeginEnd(arg1,arg2,arg3,ws.BeginGetWeather,ws.EndGetWeather)

When the computation is run, beginFunc is executed, with a callback which represents the continuation of the computation. When the callback is invoked, the overall result is fetched using endFunc.

The computation will respond to cancellation while waiting for the completion of the operation. If a cancellation occurs, and cancelAction is specified, then it is executed, and the computation continues to wait for the completion of the operation. If cancelAction is not specified, then cancellation causes the computation to stop immediately, and subsequent invocations of the callback are ignored.

For an example, see Async.FromBeginEnd<'T> Method (F#).

Platforms

Windows 7, Windows Vista SP2, Windows XP SP3, Windows XP x64 SP2, Windows Server 2008 R2, Windows Server 2008 SP2, Windows Server 2003 SP2

Version Information

F# Runtime

Supported in: 2.0, 4.0

Silverlight

Supported in: 3

See Also

Reference

Control.Async Class (F#)

Microsoft.FSharp.Control Namespace (F#)