Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Control.Async Class (F#)

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)

[<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

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#).

Member

Description

AsBeginEnd

Creates three functions that can be used to implement the .NET Framework Asynchronous Programming Model (APM) for the supplied asynchronous computation.

AwaitEvent

Creates 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.

AwaitIAsyncResult

Creates an asynchronous computation that waits for the supplied IAsyncResult.

AwaitTask

Returns an asynchronous computation that waits for the given task to complete and returns its result.

AwaitWaitHandle

Creates an asynchronous computation that waits for the supplied WaitHandle.

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 without any specific CancellationToken.

CancellationToken

Creates an asynchronous computation that returns the CancellationToken that manages the execution of the computation.

Catch

Creates 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.

DefaultCancellationToken

Gets 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.

FromContinuations

Creates an asynchronous computation that includes the current success, exception, and cancellation continuations. The callback function must eventually call exactly one of the given continuations.

Ignore

Creates an asynchronous computation that runs the given computation and ignores its result.

OnCancel

Generates a scoped, cooperative cancellation handler for use within an asynchronous workflow.

Parallel

Creates an asynchronous computation that runs all the supplied asynchronous computations, initially queuing each as a work item and using a fork/join pattern.

RunSynchronously

Runs an asynchronous computation and waits for its result.

Sleep

Creates an asynchronous computation that pauses for the specified time. A Timer object is used to schedule the delay. The operation does not block operating system threads for the duration of the delay.

Start

Starts an asynchronous computation in the thread pool. Does not wait for its result.

StartAsTask

Executes a computation in the thread pool. Returns 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.

StartChild

Starts a child computation within an asynchronous workflow. This allows multiple asynchronous computations to be executed simultaneously.

StartChildAsTask

Creates an asynchronous computation which starts the given computation as a Task.

StartImmediate

Runs an asynchronous computation, starting immediately on the current operating system thread.

StartWithContinuations

Runs an asynchronous computation, starting immediately on the current operating system thread. This method calls one of the three continuations when the operation finishes.

SwitchToContext

Creates an asynchronous computation that runs its continuation by using the Post method of the supplied synchronization context. If the supplied synchronization context is null, the asynchronous computation is equivalent to SwitchToThreadPool.

SwitchToNewThread

Creates an asynchronous computation that creates a new thread and runs its continuation in that thread.

SwitchToThreadPool

Creates an asynchronous computation that queues a work item that runs its continuation.

TryCancelled

Creates 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.

Windows 8, Windows 7, Windows Server 2012, Windows Server 2008 R2

F# Core Library Versions

Supported in: 2.0, 4.0, Portable

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.