Namespace: FSharp.Control
Assembly: FSharp.Core.dll
Base Type:
obj
See also F# Language Guide - Async Workflows.
Static member | Description |
Full Usage:
Async.RunSynchronously(computation, ?timeout, ?cancellationToken)
Parameters:
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.
|
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.
|
Full Usage:
Async.Start(computation, ?cancellationToken)
Parameters:
Async<unit>
-
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.
|
If no cancellation token is provided then the default cancellation token is used.
|
Full Usage:
Async.StartAsTask(computation, ?taskCreationOptions, ?cancellationToken)
Parameters:
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)
|
If no cancellation token is provided then the default cancellation token is used.
|
Full Usage:
Async.StartChildAsTask(computation, ?taskCreationOptions)
Parameters:
Async<'T>
?taskCreationOptions : TaskCreationOptions
Returns: Async<Task<'T>>
|
|
Full Usage:
Async.StartImmediate(computation, ?cancellationToken)
Parameters:
Async<unit>
-
The asynchronous computation to execute.
?cancellationToken : CancellationToken
-
The CancellationToken to associate with the computation.
The default is used if this parameter is not provided.
|
If no cancellation token is provided then the default cancellation token is used.
|
Full Usage:
Async.StartImmediateAsTask(computation, ?cancellationToken)
Parameters:
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)
|
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.
|
Full Usage:
Async.StartWithContinuations(computation, continuation, exceptionContinuation, cancellationContinuation, ?cancellationToken)
Parameters:
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.
|
If no cancellation token is provided then the default cancellation token is used.
|
Static member | Description |
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. |
|
Full Usage:
Async.FromContinuations(callback)
Parameters:
('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.
|
|
|
|
Full Usage:
Async.Parallel(computations, ?maxDegreeOfParallelism)
Parameters:
seq<Async<'T>>
-
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.
|
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.
|
|
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.
|
|
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.
|
Static member | Description | ||
Full Usage:
Async.AwaitEvent(event, ?cancelAction)
Parameters:
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.
|
The computation will respond to cancellation while waiting for the event. If a
cancellation occurs, and
|
||
Full Usage:
Async.AwaitIAsyncResult(iar, ?millisecondsTimeout)
Parameters:
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 .
|
The computation returns true if the handle indicated a result within the given timeout.
|
||
|
|
||
|
|
||
Full Usage:
Async.AwaitWaitHandle(waitHandle, ?millisecondsTimeout)
Parameters:
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 .
|
The computation returns true if the handle indicated a result within the given timeout.
|
||
|
|
||
|
|
Static member | Description |
Full Usage:
Async.CancelDefaultToken()
|
|
Full Usage:
Async.CancellationToken
Returns: Async<CancellationToken>
An asynchronous computation capable of retrieving the CancellationToken from a computation
expression.
|
In
|
|
|
Full Usage:
Async.DefaultCancellationToken
Returns: CancellationToken
The default CancellationToken.
|
|
Full Usage:
Async.OnCancel(interruption)
Parameters:
unit -> unit
-
The function that is executed on the thread performing the
cancellation.
Returns: Async<IDisposable>
An asynchronous computation that triggers the interruption if it is cancelled
before being disposed.
|
For example,
|
Full Usage:
Async.StartChild(computation, ?millisecondsTimeout)
Parameters:
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<Async<'T>>
A new computation that waits for the input computation to finish.
|
This method should normally be used as the immediate
right-hand-side of a 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 .
|
Full Usage:
Async.TryCancelled(computation, compensation)
Parameters:
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 |
Full Usage:
Async.SwitchToContext(syncContext)
Parameters:
SynchronizationContext
-
The synchronization context to accept the posted computation.
Returns: Async<unit>
An asynchronous computation that uses the syncContext context to execute.
|
|
|
|
|
|
Static member | Description |
Full Usage:
Async.AsBeginEnd(computation)
Parameters:
'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.
|
|
Full Usage:
Async.FromBeginEnd(arg1, arg2, arg3, beginAction, endAction, ?cancelAction)
Parameters:
'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.
|
The computation will respond to cancellation while waiting for the completion
of the operation. If a cancellation occurs, and
|
Full Usage:
Async.FromBeginEnd(arg1, arg2, beginAction, endAction, ?cancelAction)
Parameters:
'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.
|
The computation will respond to cancellation while waiting for the completion
of the operation. If a cancellation occurs, and
|
Full Usage:
Async.FromBeginEnd(arg, beginAction, endAction, ?cancelAction)
Parameters:
'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.
|
The computation will respond to cancellation while waiting for the completion
of the operation. If a cancellation occurs, and
|
Full Usage:
Async.FromBeginEnd(beginAction, endAction, ?cancelAction)
Parameters:
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.
|
The computation will respond to cancellation while waiting for the completion
of the operation. If a cancellation occurs, and
|