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

Control.Async Class (F#)

Den Delimarsky|Last Updated: 7/5/2016
|
1 Contributor

Contains members for creating and manipulating asynchronous computations. Control.Async is a static class.

Namespace/Module Path: Microsoft.FSharp.Control

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

Syntax

[<Sealed>]
type Async =
class
static member AsBeginEnd : ('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit)
static member AwaitEvent : IEvent<'Del,'T> * ?(unit -> unit) -> Async<'T>
static member AwaitIAsyncResult : IAsyncResult * ?int -> Async<bool>
static member AwaitTask : Task<'T> -> Async<'T>
static member AwaitWaitHandle : WaitHandle * ?int -> Async<bool>
static member CancelDefaultToken : unit -> unit
static member Catch : Async<'T> -> Async<Choice<'T,exn>>
static member FromBeginEnd : 'Arg1 * 'Arg2 * 'Arg3 * ('Arg1 * 'Arg2 * 'Arg3 * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * ?(unit -> unit) -> Async<'T>
static member FromBeginEnd : 'Arg1 * 'Arg2 * ('Arg1 * 'Arg2 * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * ?(unit -> unit) -> Async<'T>
static member FromBeginEnd : 'Arg1 * ('Arg1 * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * ?(unit -> unit) -> Async<'T>
static member FromBeginEnd : (AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * ?(unit -> unit) -> Async<'T>
static member FromContinuations : (('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T>
static member Ignore : Async<'T> -> Async<unit>
static member OnCancel : (unit -> unit) -> Async<IDisposable>
static member Parallel : seq<Async<'T>> -> Async<'T []>
static member RunSynchronously : Async<'T> * ?int * ?CancellationToken -> 'T
static member Sleep : int -> Async<unit>
static member Start : Async<unit> * ?CancellationToken -> unit
static member StartAsTask : Async<'T> * ?TaskCreationOptions * ?CancellationToken -> Task<'T>
static member StartChild : Async<'T> * ?int -> Async<Async<'T>>
static member StartChildAsTask : Async<'T> * ?TaskCreationOptions -> Async<Task<'T>>
static member StartImmediate : Async<unit> * ?CancellationToken -> unit
static member StartWithContinuations : Async<'T> * ('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) * ?CancellationToken -> unit
static member SwitchToContext : SynchronizationContext -> Async<unit>
static member SwitchToNewThread : unit -> Async<unit>
static member SwitchToThreadPool : unit -> Async<unit>
static member TryCancelled : Async<'T> * (OperationCanceledException -> unit) -> Async<'T>
static member CancellationToken :  Async<CancellationToken>
static member DefaultCancellationToken :  CancellationToken
end

Remarks

This type is named FSharpAsync in compiled assemblies. If you are accessing the type from a language other than F#, or through reflection, use this name.

For an overview of asynchronous workflows, see Asynchronous Workflows (F#).

Static Members

MemberDescription
AsBeginEndCreates three functions that can be used to implement the .NET Framework Asynchronous Programming Model (APM) for the supplied asynchronous computation.
AwaitEventCreates an asynchronous computation that waits for a single invocation of a .NET Framework event by adding a handler to the event. When the computation finishes or is canceled, the handler is removed from the event.
AwaitIAsyncResultCreates an asynchronous computation that waits for the supplied System.IAsyncResult.
AwaitTaskReturns an asynchronous computation that waits for the given task to complete and returns its result.
AwaitWaitHandleCreates an asynchronous computation that waits for the supplied System.Threading.WaitHandle.
CancelDefaultTokenRaises the cancellation condition for the most recent set of asynchronous computations started without any specific System.Threading.CancellationToken. Replaces the global System.Threading.CancellationTokenSource with a new global token source for any asynchronous computations created without any specific System.Threading.CancellationToken.
CancellationTokenCreates an asynchronous computation that returns the System.Threading.CancellationToken that manages the execution of the computation.
CatchCreates an asynchronous computation. If this computation finishes successfully, this method returns Choice1Of2 with the returned value. If this computation raises an exception before it finishes, this method returns Choice2Of2 with the raised exception.
DefaultCancellationTokenGets the default cancellation token for running asynchronous computations.
FromBeginEnd<'T>Creates an asynchronous computation by specifying a beginning and ending function, like .NET Framework APIs.
FromBeginEnd<'Arg1,'T>Creates an asynchronous computation by specifying a beginning and ending function, like .NET Framework APIs. This overload should be used if the operation is qualified by one argument.
FromBeginEnd<'Arg1,'Arg2,'T>Creates an asynchronous computation by specifying a beginning and ending function, like .NET Framework APIs. This overload should be used if the operation is qualified by two arguments.
FromBeginEnd<'Arg1,'Arg2,'Arg3,'T>Creates an asynchronous computation by specifying a beginning and ending function, like .NET Framework APIs. This overload should be used if the operation is qualified by three arguments.
FromContinuationsCreates an asynchronous computation that includes the current success, exception, and cancellation continuations. The callback function must eventually call exactly one of the given continuations.
IgnoreCreates an asynchronous computation that runs the given computation and ignores its result.
OnCancelGenerates a scoped, cooperative cancellation handler for use within an asynchronous workflow.
ParallelCreates an asynchronous computation that runs all the supplied asynchronous computations, initially queuing each as a work item and using a fork/join pattern.
RunSynchronouslyRuns an asynchronous computation and waits for its result.
SleepCreates an asynchronous computation that pauses for the specified time. A System.Threading.Timer object is used to schedule the delay. The operation does not block operating system threads for the duration of the delay.
StartStarts an asynchronous computation in the thread pool. Does not wait for its result.
StartAsTaskExecutes a computation in the thread pool. Returns a System.Threading.Tasks.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.
StartChildStarts a child computation within an asynchronous workflow. This allows multiple asynchronous computations to be executed simultaneously.
StartChildAsTaskCreates an asynchronous computation which starts the given computation as a System.Threading.Tasks.Task.
StartImmediateRuns an asynchronous computation, starting immediately on the current operating system thread.
StartWithContinuationsRuns an asynchronous computation, starting immediately on the current operating system thread. This method calls one of the three continuations when the operation finishes.
SwitchToContextCreates an asynchronous computation that runs its continuation by using the System.Threading.SynchronizationContext.Post(System.Threading.SendOrPostCallback,System.Object) method of the supplied synchronization context. If the supplied synchronization context is null, the asynchronous computation is equivalent to SwitchToThreadPool.
SwitchToNewThreadCreates an asynchronous computation that creates a new thread and runs its continuation in that thread.
SwitchToThreadPoolCreates an asynchronous computation that queues a work item that runs its continuation.
TryCancelledCreates an asynchronous computation that runs the supplied computation. If this computation is cancelled before it finishes, the computation generated by running the supplied compensation function is executed.

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

Microsoft.FSharp.Control Namespace (F#)

Asynchronous Workflows (F#)

Control.Async<'T> Type (F#)

© 2017 Microsoft