## Async Type

Holds static members for creating and manipulating asynchronous computations.

## Starting Async Computations

### Static members

 Static member Description  Async.RunSynchronously(computation, ?timeout, ?cancellationToken)  Full Usage: Async.RunSynchronously(computation, ?timeout, ?cancellationToken) Parameters: computation : Async<'T> - The computation to run. ?timeout : int - The amount of time in milliseconds to wait for the result of the computation before raising a TimeoutException. If no value is provided for timeout then a default of -1 is used to correspond to Timeout.Infinite. If a cancellable cancellationToken is provided, timeout parameter will be ignored ?cancellationToken : CancellationToken - The cancellation token to be associated with the computation. If one is not supplied, the default cancellation token is used. Returns: 'T The result of the computation. Runs the asynchronous computation and await its result. If an exception occurs in the asynchronous computation then an exception is re-raised by this function. If no cancellation token is provided then the default cancellation token is used. The timeout parameter is given in milliseconds. A value of -1 is equivalent to System.Threading.Timeout.Infinite. computation : Async<'T> The computation to run. ?timeout : int The amount of time in milliseconds to wait for the result of the computation before raising a TimeoutException. If no value is provided for timeout then a default of -1 is used to correspond to Timeout.Infinite. If a cancellable cancellationToken is provided, timeout parameter will be ignored ?cancellationToken : CancellationToken The cancellation token to be associated with the computation. If one is not supplied, the default cancellation token is used. Returns: 'T The result of the computation.  Async.Start(computation, ?cancellationToken)  Full Usage: Async.Start(computation, ?cancellationToken) Parameters: computation : Async - The computation to run asynchronously. ?cancellationToken : CancellationToken - The cancellation token to be associated with the computation. If one is not supplied, the default cancellation token is used. Starts the asynchronous computation in the thread pool. Do not await its result. If no cancellation token is provided then the default cancellation token is used. computation : Async The computation to run asynchronously. ?cancellationToken : CancellationToken The cancellation token to be associated with the computation. If one is not supplied, the default cancellation token is used.  Async.StartAsTask(computation, ?taskCreationOptions, ?cancellationToken)  Full Usage: Async.StartAsTask(computation, ?taskCreationOptions, ?cancellationToken) Parameters: computation : Async<'T> ?taskCreationOptions : TaskCreationOptions ?cancellationToken : CancellationToken Returns: Task<'T> A Task that will be completed in the corresponding state once the computation terminates (produces the result, throws exception or gets canceled) Executes a computation in the thread pool. If no cancellation token is provided then the default cancellation token is used. computation : Async<'T> ?taskCreationOptions : TaskCreationOptions ?cancellationToken : CancellationToken Returns: Task<'T> A Task that will be completed in the corresponding state once the computation terminates (produces the result, throws exception or gets canceled)  Async.StartChildAsTask(computation, ?taskCreationOptions)  Full Usage: Async.StartChildAsTask(computation, ?taskCreationOptions) Parameters: computation : Async<'T> ?taskCreationOptions : TaskCreationOptions Returns: Async> Creates an asynchronous computation which starts the given computation as a Task computation : Async<'T> ?taskCreationOptions : TaskCreationOptions Returns: Async>  Async.StartImmediate(computation, ?cancellationToken)  Full Usage: Async.StartImmediate(computation, ?cancellationToken) Parameters: computation : Async - The asynchronous computation to execute. ?cancellationToken : CancellationToken - The CancellationToken to associate with the computation. The default is used if this parameter is not provided. Runs an asynchronous computation, starting immediately on the current operating system thread. If no cancellation token is provided then the default cancellation token is used. computation : Async The asynchronous computation to execute. ?cancellationToken : CancellationToken The CancellationToken to associate with the computation. The default is used if this parameter is not provided.  Async.StartImmediateAsTask(computation, ?cancellationToken)  Full Usage: Async.StartImmediateAsTask(computation, ?cancellationToken) Parameters: computation : Async<'T> - The asynchronous computation to execute. ?cancellationToken : CancellationToken - The CancellationToken to associate with the computation. The default is used if this parameter is not provided. Returns: Task<'T> A Task that will be completed in the corresponding state once the computation terminates (produces the result, throws exception or gets canceled) Runs an asynchronous computation, starting immediately on the current operating system thread, but also returns the execution as Task If no cancellation token is provided then the default cancellation token is used. You may prefer using this method if you want to achive a similar behviour to async await in C# as async computation starts on the current thread with an ability to return a result. computation : Async<'T> The asynchronous computation to execute. ?cancellationToken : CancellationToken The CancellationToken to associate with the computation. The default is used if this parameter is not provided. Returns: Task<'T> A Task that will be completed in the corresponding state once the computation terminates (produces the result, throws exception or gets canceled)  Async.StartWithContinuations(computation, continuation, exceptionContinuation, cancellationContinuation, ?cancellationToken)  Full Usage: Async.StartWithContinuations(computation, continuation, exceptionContinuation, cancellationContinuation, ?cancellationToken) Parameters: computation : Async<'T> - The asynchronous computation to execute. continuation : 'T -> unit - The function called on success. exceptionContinuation : exn -> unit - The function called on exception. cancellationContinuation : OperationCanceledException -> unit - The function called on cancellation. ?cancellationToken : CancellationToken - The CancellationToken to associate with the computation. The default is used if this parameter is not provided. Runs an asynchronous computation, starting immediately on the current operating system thread. Call one of the three continuations when the operation completes. If no cancellation token is provided then the default cancellation token is used. computation : Async<'T> The asynchronous computation to execute. continuation : 'T -> unit The function called on success. exceptionContinuation : exn -> unit The function called on exception. cancellationContinuation : OperationCanceledException -> unit The function called on cancellation. ?cancellationToken : CancellationToken The CancellationToken to associate with the computation. The default is used if this parameter is not provided.

## Composing Async Computations

### Static members

 Static member Description  Async.Choice(computations)  Full Usage: Async.Choice(computations) Parameters: computations : seq> - A sequence of computations to be parallelized. Returns: Async<'T option> A computation that returns the first succeeding computation. Creates an asynchronous computation that executes all given asynchronous computations in parallel, returning the result of the first succeeding computation (one whose result is 'Some x'). If all child computations complete with None, the parent computation also returns None. If any child computation raises an exception, then the overall computation will trigger an exception, and cancel the others. The overall computation will respond to cancellation while executing the child computations. If cancelled, the computation will cancel any remaining child computations but will still wait for the other child computations to complete. computations : seq> A sequence of computations to be parallelized. Returns: Async<'T option> A computation that returns the first succeeding computation.  Async.FromContinuations(callback)  Full Usage: Async.FromContinuations(callback) Parameters: callback : ('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit - The function that accepts the current success, exception, and cancellation continuations. Returns: Async<'T> An asynchronous computation that provides the callback with the current continuations. Creates an asynchronous computation that captures the current success, exception and cancellation continuations. The callback must eventually call exactly one of the given continuations. callback : ('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit The function that accepts the current success, exception, and cancellation continuations. Returns: Async<'T> An asynchronous computation that provides the callback with the current continuations.  Async.Ignore(computation)  Full Usage: Async.Ignore(computation) Parameters: computation : Async<'T> - The input computation. Returns: Async A computation that is equivalent to the input computation, but disregards the result. Creates an asynchronous computation that runs the given computation and ignores its result. computation : Async<'T> The input computation. Returns: Async A computation that is equivalent to the input computation, but disregards the result.  Async.Parallel(computations, ?maxDegreeOfParallelism)  Full Usage: Async.Parallel(computations, ?maxDegreeOfParallelism) Parameters: computations : seq> - A sequence of distinct computations to be parallelized. ?maxDegreeOfParallelism : int - The maximum degree of parallelism in the parallel execution. Returns: Async<'T[]> A computation that returns an array of values from the sequence of input computations. Creates an asynchronous computation that executes all the given asynchronous computations, initially queueing each as work items and using a fork/join pattern. If all child computations succeed, an array of results is passed to the success continuation. If any child computation raises an exception, then the overall computation will trigger an exception, and cancel the others. The overall computation will respond to cancellation while executing the child computations. If cancelled, the computation will cancel any remaining child computations but will still wait for the other child computations to complete. computations : seq> A sequence of distinct computations to be parallelized. ?maxDegreeOfParallelism : int The maximum degree of parallelism in the parallel execution. Returns: Async<'T[]> A computation that returns an array of values from the sequence of input computations.  Async.Parallel(computations)  Full Usage: Async.Parallel(computations) Parameters: computations : seq> - A sequence of distinct computations to be parallelized. Returns: Async<'T[]> A computation that returns an array of values from the sequence of input computations. Creates an asynchronous computation that executes all the given asynchronous computations, initially queueing each as work items and using a fork/join pattern. If all child computations succeed, an array of results is passed to the success continuation. If any child computation raises an exception, then the overall computation will trigger an exception, and cancel the others. The overall computation will respond to cancellation while executing the child computations. If cancelled, the computation will cancel any remaining child computations but will still wait for the other child computations to complete. computations : seq> A sequence of distinct computations to be parallelized. Returns: Async<'T[]> A computation that returns an array of values from the sequence of input computations.  Async.Sequential(computations)  Full Usage: Async.Sequential(computations) Parameters: computations : seq> - A sequence of distinct computations to be run in sequence. Returns: Async<'T[]> A computation that returns an array of values from the sequence of input computations. Creates an asynchronous computation that executes all the given asynchronous computations sequentially. If all child computations succeed, an array of results is passed to the success continuation. If any child computation raises an exception, then the overall computation will trigger an exception, and cancel the others. The overall computation will respond to cancellation while executing the child computations. If cancelled, the computation will cancel any remaining child computations but will still wait for the other child computations to complete. computations : seq> A sequence of distinct computations to be run in sequence. Returns: Async<'T[]> A computation that returns an array of values from the sequence of input computations.

## Awaiting Results

### Static members

Static member Description
 Async.AwaitEvent(event, ?cancelAction) 
Full Usage: Async.AwaitEvent(event, ?cancelAction)

Parameters:
event : IEvent<'Del, 'T> - The event to handle once.
?cancelAction : unit -> unit - An optional function to execute instead of cancelling when a cancellation is issued.

Returns: Async<'T> An asynchronous computation that waits for the event to be invoked.

Creates an asynchronous computation that waits for a single invocation of a CLI event by adding a handler to the event. Once the computation completes or is cancelled, the handler is removed from the event.

The computation will respond to cancellation while waiting for the event. If a cancellation occurs, and cancelAction is specified, then it is executed, and the computation continues to wait for the event. If cancelAction is not specified, then cancellation causes the computation to cancel immediately.

event : IEvent<'Del, 'T>

The event to handle once.

?cancelAction : unit -> unit

An optional function to execute instead of cancelling when a cancellation is issued.

Returns: Async<'T>

An asynchronous computation that waits for the event to be invoked.

 Async.AwaitIAsyncResult(iar, ?millisecondsTimeout) 
Full Usage: Async.AwaitIAsyncResult(iar, ?millisecondsTimeout)

Parameters:
iar : IAsyncResult - The IAsyncResult to wait on.
?millisecondsTimeout : int - The timeout value in milliseconds. If one is not provided then the default value of -1 corresponding to Timeout.Infinite.

Returns: Async<bool> An asynchronous computation that waits on the given IAsyncResult.

Creates an asynchronous computation that will wait on the IAsyncResult.

The computation returns true if the handle indicated a result within the given timeout.

iar : IAsyncResult

The IAsyncResult to wait on.

?millisecondsTimeout : int

The timeout value in milliseconds. If one is not provided then the default value of -1 corresponding to Timeout.Infinite.

Returns: Async<bool>

An asynchronous computation that waits on the given IAsyncResult.

 Async.AwaitTask(task) 
Full Usage: Async.AwaitTask(task)

Parameters:
task : Task - The task to await.

Returns: Async<unit>

Return an asynchronous computation that will wait for the given task to complete and return its result.

task : Task

Returns: Async<unit>
 Async.AwaitTask(task) 
Full Usage: Async.AwaitTask(task)

Parameters:
task : Task<'T> - The task to await.

Returns: Async<'T>

Return an asynchronous computation that will wait for the given task to complete and return its result.

task : Task<'T>

Returns: Async<'T>
 Async.AwaitWaitHandle(waitHandle, ?millisecondsTimeout) 
Full Usage: Async.AwaitWaitHandle(waitHandle, ?millisecondsTimeout)

Parameters:
waitHandle : WaitHandle - The WaitHandle that can be signalled.
?millisecondsTimeout : int - The timeout value in milliseconds. If one is not provided then the default value of -1 corresponding to Timeout.Infinite.

Returns: Async<bool> An asynchronous computation that waits on the given WaitHandle.

Creates an asynchronous computation that will wait on the given WaitHandle.

The computation returns true if the handle indicated a result within the given timeout.

waitHandle : WaitHandle

The WaitHandle that can be signalled.

?millisecondsTimeout : int

The timeout value in milliseconds. If one is not provided then the default value of -1 corresponding to Timeout.Infinite.

Returns: Async<bool>

An asynchronous computation that waits on the given WaitHandle.

 Async.Sleep(dueTime) 
Full Usage: Async.Sleep(dueTime)

Parameters:
dueTime : TimeSpan - The amount of time to sleep.

Returns: Async<unit> An asynchronous computation that will sleep for the given time.

Creates an asynchronous computation that will sleep for the given time. This is scheduled using a System.Threading.Timer object. The operation will not block operating system threads for the duration of the wait.

dueTime : TimeSpan

The amount of time to sleep.

Returns: Async<unit>

An asynchronous computation that will sleep for the given time.

 ArgumentOutOfRangeException Thrown when the due time is negative.
 Async.Sleep(millisecondsDueTime) 
Full Usage: Async.Sleep(millisecondsDueTime)

Parameters:
millisecondsDueTime : int - The number of milliseconds to sleep.

Returns: Async<unit> An asynchronous computation that will sleep for the given time.

Creates an asynchronous computation that will sleep for the given time. This is scheduled using a System.Threading.Timer object. The operation will not block operating system threads for the duration of the wait.

millisecondsDueTime : int

The number of milliseconds to sleep.

Returns: Async<unit>

An asynchronous computation that will sleep for the given time.

 ArgumentOutOfRangeException Thrown when the due time is negative and not infinite.

## Cancellation and Exceptions

### Static members

 Static member Description  Async.CancelDefaultToken()  Full Usage: Async.CancelDefaultToken() Raises the cancellation condition for the most recent set of asynchronous computations started without any specific CancellationToken. Replaces the global CancellationTokenSource with a new global token source for any asynchronous computations created after this point without any specific CancellationToken.  Async.CancellationToken  Full Usage: Async.CancellationToken Returns: Async An asynchronous computation capable of retrieving the CancellationToken from a computation expression. Creates an asynchronous computation that returns the CancellationToken governing the execution of the computation. In async { let! token = Async.CancellationToken ...} token can be used to initiate other asynchronous operations that will cancel cooperatively with this workflow. Returns: Async An asynchronous computation capable of retrieving the CancellationToken from a computation expression.  Async.Catch(computation)  Full Usage: Async.Catch(computation) Parameters: computation : Async<'T> - The input computation that returns the type T. Returns: Async> A computation that returns a choice of type T or exception. Creates an asynchronous computation that executes computation. If this computation completes successfully then return Choice1Of2 with the returned value. If this computation raises an exception before it completes then return Choice2Of2 with the raised exception. computation : Async<'T> The input computation that returns the type T. Returns: Async> A computation that returns a choice of type T or exception.  Async.DefaultCancellationToken  Full Usage: Async.DefaultCancellationToken Returns: CancellationToken The default CancellationToken. Gets the default cancellation token for executing asynchronous computations. Returns: CancellationToken The default CancellationToken.  Async.OnCancel(interruption)  Full Usage: Async.OnCancel(interruption) Parameters: interruption : unit -> unit - The function that is executed on the thread performing the cancellation. Returns: Async An asynchronous computation that triggers the interruption if it is cancelled before being disposed. Generates a scoped, cooperative cancellation handler for use within an asynchronous workflow. For example, async { use! holder = Async.OnCancel interruption ... } generates an asynchronous computation where, if a cancellation happens any time during the execution of the asynchronous computation in the scope of holder, then action interruption is executed on the thread that is performing the cancellation. This can be used to arrange for a computation to be asynchronously notified that a cancellation has occurred, e.g. by setting a flag, or deregistering a pending I/O action. interruption : unit -> unit The function that is executed on the thread performing the cancellation. Returns: Async An asynchronous computation that triggers the interruption if it is cancelled before being disposed.  Async.StartChild(computation, ?millisecondsTimeout)  Full Usage: Async.StartChild(computation, ?millisecondsTimeout) Parameters: computation : Async<'T> - The child computation. ?millisecondsTimeout : int - The timeout value in milliseconds. If one is not provided then the default value of -1 corresponding to Timeout.Infinite. Returns: Async> A new computation that waits for the input computation to finish. Starts a child computation within an asynchronous workflow. This allows multiple asynchronous computations to be executed simultaneously. This method should normally be used as the immediate right-hand-side of a let! binding in an F# asynchronous workflow, that is,  async { ... let! completor1 = childComputation1 |> Async.StartChild let! completor2 = childComputation2 |> Async.StartChild ... let! result1 = completor1 let! result2 = completor2 ... } When used in this way, each use of StartChild starts an instance of childComputation and returns a completor object representing a computation to wait for the completion of the operation. When executed, the completor awaits the completion of childComputation. computation : Async<'T> The child computation. ?millisecondsTimeout : int The timeout value in milliseconds. If one is not provided then the default value of -1 corresponding to Timeout.Infinite. Returns: Async> A new computation that waits for the input computation to finish.  Async.TryCancelled(computation, compensation)  Full Usage: Async.TryCancelled(computation, compensation) Parameters: computation : Async<'T> - The input asynchronous computation. compensation : OperationCanceledException -> unit - The function to be run if the computation is cancelled. Returns: Async<'T> An asynchronous computation that runs the compensation if the input computation is cancelled. Creates an asynchronous computation that executes computation. If this computation is cancelled before it completes then the computation generated by running compensation is executed. computation : Async<'T> The input asynchronous computation. compensation : OperationCanceledException -> unit The function to be run if the computation is cancelled. Returns: Async<'T> An asynchronous computation that runs the compensation if the input computation is cancelled.

 Static member Description  Async.SwitchToContext(syncContext)  Full Usage: Async.SwitchToContext(syncContext) Parameters: syncContext : SynchronizationContext - The synchronization context to accept the posted computation. Returns: Async An asynchronous computation that uses the syncContext context to execute. Creates an asynchronous computation that runs its continuation using syncContext.Post. If syncContext is null then the asynchronous computation is equivalent to SwitchToThreadPool(). syncContext : SynchronizationContext The synchronization context to accept the posted computation. Returns: Async An asynchronous computation that uses the syncContext context to execute.  Async.SwitchToNewThread()  Full Usage: Async.SwitchToNewThread() Returns: Async A computation that will execute on a new thread. Creates an asynchronous computation that creates a new thread and runs its continuation in that thread. Returns: Async A computation that will execute on a new thread.  Async.SwitchToThreadPool()  Full Usage: Async.SwitchToThreadPool() Returns: Async A computation that generates a new work item in the thread pool. Creates an asynchronous computation that queues a work item that runs its continuation. Returns: Async A computation that generates a new work item in the thread pool.
 Static member Description  Async.AsBeginEnd(computation)  Full Usage: Async.AsBeginEnd(computation) Parameters: computation : 'Arg -> Async<'T> - A function generating the asynchronous computation to split into the traditional .NET Asynchronous Programming Model. Returns: ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit) A tuple of the begin, end, and cancel members. Creates three functions that can be used to implement the .NET 1.0 Asynchronous Programming Model (APM) for a given asynchronous computation. computation : 'Arg -> Async<'T> A function generating the asynchronous computation to split into the traditional .NET Asynchronous Programming Model. Returns: ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit) A tuple of the begin, end, and cancel members.  Async.FromBeginEnd(arg1, arg2, arg3, beginAction, endAction, ?cancelAction)  Full Usage: Async.FromBeginEnd(arg1, arg2, arg3, beginAction, endAction, ?cancelAction) Parameters: arg1 : 'Arg1 - The first argument for the operation. arg2 : 'Arg2 - The second argument for the operation. arg3 : 'Arg3 - The third argument for the operation. beginAction : 'Arg1 * 'Arg2 * 'Arg3 * AsyncCallback * obj -> IAsyncResult - The function initiating a traditional CLI asynchronous operation. endAction : IAsyncResult -> 'T - The function completing a traditional CLI asynchronous operation. ?cancelAction : unit -> unit - An optional function to be executed when a cancellation is requested. Returns: Async<'T> An asynchronous computation wrapping the given Begin/End functions. Creates an asynchronous computation in terms of a Begin/End pair of actions in the style used in .NET 2.0 APIs. 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. arg1 : 'Arg1 The first argument for the operation. arg2 : 'Arg2 The second argument for the operation. arg3 : 'Arg3 The third argument for the operation. beginAction : 'Arg1 * 'Arg2 * 'Arg3 * AsyncCallback * obj -> IAsyncResult The function initiating a traditional CLI asynchronous operation. endAction : IAsyncResult -> 'T The function completing a traditional CLI asynchronous operation. ?cancelAction : unit -> unit An optional function to be executed when a cancellation is requested. Returns: Async<'T> An asynchronous computation wrapping the given Begin/End functions.  Async.FromBeginEnd(arg1, arg2, beginAction, endAction, ?cancelAction)  Full Usage: Async.FromBeginEnd(arg1, arg2, beginAction, endAction, ?cancelAction) Parameters: arg1 : 'Arg1 - The first argument for the operation. arg2 : 'Arg2 - The second argument for the operation. beginAction : 'Arg1 * 'Arg2 * AsyncCallback * obj -> IAsyncResult - The function initiating a traditional CLI asynchronous operation. endAction : IAsyncResult -> 'T - The function completing a traditional CLI asynchronous operation. ?cancelAction : unit -> unit - An optional function to be executed when a cancellation is requested. Returns: Async<'T> An asynchronous computation wrapping the given Begin/End functions. Creates an asynchronous computation in terms of a Begin/End pair of actions in the style used in .NET 2.0 APIs. 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. arg1 : 'Arg1 The first argument for the operation. arg2 : 'Arg2 The second argument for the operation. beginAction : 'Arg1 * 'Arg2 * AsyncCallback * obj -> IAsyncResult The function initiating a traditional CLI asynchronous operation. endAction : IAsyncResult -> 'T The function completing a traditional CLI asynchronous operation. ?cancelAction : unit -> unit An optional function to be executed when a cancellation is requested. Returns: Async<'T> An asynchronous computation wrapping the given Begin/End functions.  Async.FromBeginEnd(arg, beginAction, endAction, ?cancelAction)  Full Usage: Async.FromBeginEnd(arg, beginAction, endAction, ?cancelAction) Parameters: arg : 'Arg1 - The argument for the operation. beginAction : 'Arg1 * AsyncCallback * obj -> IAsyncResult - The function initiating a traditional CLI asynchronous operation. endAction : IAsyncResult -> 'T - The function completing a traditional CLI asynchronous operation. ?cancelAction : unit -> unit - An optional function to be executed when a cancellation is requested. Returns: Async<'T> An asynchronous computation wrapping the given Begin/End functions. Creates an asynchronous computation in terms of a Begin/End pair of actions in the style used in .NET 2.0 APIs. 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. arg : 'Arg1 The argument for the operation. beginAction : 'Arg1 * AsyncCallback * obj -> IAsyncResult The function initiating a traditional CLI asynchronous operation. endAction : IAsyncResult -> 'T The function completing a traditional CLI asynchronous operation. ?cancelAction : unit -> unit An optional function to be executed when a cancellation is requested. Returns: Async<'T> An asynchronous computation wrapping the given Begin/End functions.  Async.FromBeginEnd(beginAction, endAction, ?cancelAction)  Full Usage: Async.FromBeginEnd(beginAction, endAction, ?cancelAction) Parameters: beginAction : AsyncCallback * obj -> IAsyncResult - The function initiating a traditional CLI asynchronous operation. endAction : IAsyncResult -> 'T - The function completing a traditional CLI asynchronous operation. ?cancelAction : unit -> unit - An optional function to be executed when a cancellation is requested. Returns: Async<'T> An asynchronous computation wrapping the given Begin/End functions. Creates an asynchronous computation in terms of a Begin/End pair of actions in the style used in CLI APIs. 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. beginAction : AsyncCallback * obj -> IAsyncResult The function initiating a traditional CLI asynchronous operation. endAction : IAsyncResult -> 'T The function completing a traditional CLI asynchronous operation. ?cancelAction : unit -> unit An optional function to be executed when a cancellation is requested. Returns: Async<'T> An asynchronous computation wrapping the given Begin/End functions.