obj
Holds static members for creating and manipulating asynchronous computations.
Table of contents
Async.RunSynchronously(computation, ?timeout, ?cancellationToken)
Full Usage:
Async.RunSynchronously(computation, ?timeout, ?cancellationToken)
Parameters:
Async<'T>
- The computation to run.
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.
CancellationToken
- The cancellation token to be associated with the computation. If one is not supplied, the default cancellation token is used.
'T
The result of the computation.
Runs the asynchronous computation and await its result.
Async<'T>
The computation to run.
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.
CancellationToken
The cancellation token to be associated with the computation. If one is not supplied, the default cancellation token is used.
'T
The result of the computation.
printfn "A"
let result = async {
printfn "B"
do! Async.Sleep(1000)
printfn "C"
17
} |> Async.RunSynchronously
printfn "D"
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
val result: Async<unit>
val async: AsyncBuilder
Multiple items
type Async = static member AsBeginEnd: computation: ('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit) static member AwaitEvent: event: IEvent<'Del,'T> * ?cancelAction: (unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate) static member AwaitIAsyncResult: iar: IAsyncResult * ?millisecondsTimeout: int -> Async<bool> static member AwaitTask: task: Task<'T> -> Async<'T> + 1 overload static member AwaitWaitHandle: waitHandle: WaitHandle * ?millisecondsTimeout: int -> Async<bool> static member CancelDefaultToken: unit -> unit static member Catch: computation: Async<'T> -> Async<Choice<'T,exn>> static member Choice: computations: Async<'T option> seq -> Async<'T option> static member FromBeginEnd: beginAction: (AsyncCallback * obj -> IAsyncResult) * endAction: (IAsyncResult -> 'T) * ?cancelAction: (unit -> unit) -> Async<'T> + 3 overloads static member FromContinuations: callback: (('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T> ...
--------------------
type Async<'T>
static member Async.Sleep: dueTime: System.TimeSpan -> Async<unit>
static member Async.Sleep: millisecondsDueTime: int -> Async<unit>
static member Async.RunSynchronously: computation: Async<'T> * ?timeout: int * ?cancellationToken: System.Threading.CancellationToken -> 'T
Prints "A", "B" immediately, then "C", "D" in 1 second. result is set to 17.
Full Usage:
Async.Start(computation, ?cancellationToken)
Parameters:
Async<unit>
- The computation to run asynchronously.
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.
Async<unit>
The computation to run asynchronously.
CancellationToken
The cancellation token to be associated with the computation. If one is not supplied, the default cancellation token is used.
printfn "A"
async {
printfn "B"
do! Async.Sleep(1000)
printfn "C"
} |> Async.Start
printfn "D"
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
val async: AsyncBuilder
Multiple items
type Async = static member AsBeginEnd: computation: ('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit) static member AwaitEvent: event: IEvent<'Del,'T> * ?cancelAction: (unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate) static member AwaitIAsyncResult: iar: IAsyncResult * ?millisecondsTimeout: int -> Async<bool> static member AwaitTask: task: Task<'T> -> Async<'T> + 1 overload static member AwaitWaitHandle: waitHandle: WaitHandle * ?millisecondsTimeout: int -> Async<bool> static member CancelDefaultToken: unit -> unit static member Catch: computation: Async<'T> -> Async<Choice<'T,exn>> static member Choice: computations: Async<'T option> seq -> Async<'T option> static member FromBeginEnd: beginAction: (AsyncCallback * obj -> IAsyncResult) * endAction: (IAsyncResult -> 'T) * ?cancelAction: (unit -> unit) -> Async<'T> + 3 overloads static member FromContinuations: callback: (('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T> ...
--------------------
type Async<'T>
static member Async.Sleep: dueTime: System.TimeSpan -> Async<unit>
static member Async.Sleep: millisecondsDueTime: int -> Async<unit>
static member Async.Start: computation: Async<unit> * ?cancellationToken: System.Threading.CancellationToken -> unit
Prints "A", then "D", "B" quickly in any order, and then "C" in 1 second.
Async.StartAsTask(computation, ?taskCreationOptions, ?cancellationToken)
Full Usage:
Async.StartAsTask(computation, ?taskCreationOptions, ?cancellationToken)
Parameters:
Async<'T>
TaskCreationOptions
CancellationToken
Task<'T>
A
Taskthat 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.
Async<'T>
TaskCreationOptions
CancellationToken
Task<'T>
A Task that will be completed in the corresponding state once the computation terminates (produces the result, throws exception or gets canceled)
printfn "A"
let t =
async {
printfn "B"
do! Async.Sleep(1000)
printfn "C"
} |> Async.StartAsTask
printfn "D"
t.Wait()
printfn "E"
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
val t: System.Threading.Tasks.Task<unit>
val async: AsyncBuilder
Multiple items
type Async = static member AsBeginEnd: computation: ('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit) static member AwaitEvent: event: IEvent<'Del,'T> * ?cancelAction: (unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate) static member AwaitIAsyncResult: iar: IAsyncResult * ?millisecondsTimeout: int -> Async<bool> static member AwaitTask: task: Task<'T> -> Async<'T> + 1 overload static member AwaitWaitHandle: waitHandle: WaitHandle * ?millisecondsTimeout: int -> Async<bool> static member CancelDefaultToken: unit -> unit static member Catch: computation: Async<'T> -> Async<Choice<'T,exn>> static member Choice: computations: Async<'T option> seq -> Async<'T option> static member FromBeginEnd: beginAction: (AsyncCallback * obj -> IAsyncResult) * endAction: (IAsyncResult -> 'T) * ?cancelAction: (unit -> unit) -> Async<'T> + 3 overloads static member FromContinuations: callback: (('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T> ...
--------------------
type Async<'T>
static member Async.Sleep: dueTime: System.TimeSpan -> Async<unit>
static member Async.Sleep: millisecondsDueTime: int -> Async<unit>
static member Async.StartAsTask: computation: Async<'T> * ?taskCreationOptions: System.Threading.Tasks.TaskCreationOptions * ?cancellationToken: System.Threading.CancellationToken -> System.Threading.Tasks.Task<'T>
System.Threading.Tasks.Task.Wait() : unit
System.Threading.Tasks.Task.Wait(timeout: System.TimeSpan) : bool
System.Threading.Tasks.Task.Wait(cancellationToken: System.Threading.CancellationToken) : unit
System.Threading.Tasks.Task.Wait(millisecondsTimeout: int) : bool
System.Threading.Tasks.Task.Wait(timeout: System.TimeSpan, cancellationToken: System.Threading.CancellationToken) : bool
System.Threading.Tasks.Task.Wait(millisecondsTimeout: int, cancellationToken: System.Threading.CancellationToken) : bool
Full Usage:
Async.StartChildAsTask(computation, ?taskCreationOptions)
Parameters:
Async<'T>
TaskCreationOptions
Async<Task<'T>>
Creates an asynchronous computation which starts the given computation as a Task
Async<'T>
TaskCreationOptions
Async<Task<'T>>
Full Usage:
Async.StartImmediate(computation, ?cancellationToken)
Parameters:
Async<unit>
- The asynchronous computation to execute.
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.
Async<unit>
The asynchronous computation to execute.
CancellationToken
The CancellationToken
to associate with the computation. The default is used if this parameter is not provided.
printfn "A"
async {
printfn "B"
do! Async.Sleep(1000)
printfn "C"
} |> Async.StartImmediate
printfn "D"
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
val async: AsyncBuilder
Multiple items
type Async = static member AsBeginEnd: computation: ('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit) static member AwaitEvent: event: IEvent<'Del,'T> * ?cancelAction: (unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate) static member AwaitIAsyncResult: iar: IAsyncResult * ?millisecondsTimeout: int -> Async<bool> static member AwaitTask: task: Task<'T> -> Async<'T> + 1 overload static member AwaitWaitHandle: waitHandle: WaitHandle * ?millisecondsTimeout: int -> Async<bool> static member CancelDefaultToken: unit -> unit static member Catch: computation: Async<'T> -> Async<Choice<'T,exn>> static member Choice: computations: Async<'T option> seq -> Async<'T option> static member FromBeginEnd: beginAction: (AsyncCallback * obj -> IAsyncResult) * endAction: (IAsyncResult -> 'T) * ?cancelAction: (unit -> unit) -> Async<'T> + 3 overloads static member FromContinuations: callback: (('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T> ...
--------------------
type Async<'T>
static member Async.Sleep: dueTime: System.TimeSpan -> Async<unit>
static member Async.Sleep: millisecondsDueTime: int -> Async<unit>
static member Async.StartImmediate: computation: Async<unit> * ?cancellationToken: System.Threading.CancellationToken -> unit
Prints "A", "B", "D" immediately, then "C" in 1 second
Full Usage:
Async.StartImmediateAsTask(computation, ?cancellationToken)
Parameters:
Async<'T>
- The asynchronous computation to execute.
CancellationToken
- The CancellationToken
to associate with the computation. The default is used if this parameter is not provided.
Task<'T>
A
Taskthat 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
Async<'T>
The asynchronous computation to execute.
CancellationToken
The CancellationToken
to associate with the computation. The default is used if this parameter is not provided.
Task<'T>
A Task that will be completed in the corresponding state once the computation terminates (produces the result, throws exception or gets canceled)
printfn "A"
let t =
async {
printfn "B"
do! Async.Sleep(1000)
printfn "C"
} |> Async.StartImmediateAsTask
printfn "D"
t.Wait()
printfn "E"
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
val t: System.Threading.Tasks.Task<unit>
val async: AsyncBuilder
Multiple items
type Async = static member AsBeginEnd: computation: ('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit) static member AwaitEvent: event: IEvent<'Del,'T> * ?cancelAction: (unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate) static member AwaitIAsyncResult: iar: IAsyncResult * ?millisecondsTimeout: int -> Async<bool> static member AwaitTask: task: Task<'T> -> Async<'T> + 1 overload static member AwaitWaitHandle: waitHandle: WaitHandle * ?millisecondsTimeout: int -> Async<bool> static member CancelDefaultToken: unit -> unit static member Catch: computation: Async<'T> -> Async<Choice<'T,exn>> static member Choice: computations: Async<'T option> seq -> Async<'T option> static member FromBeginEnd: beginAction: (AsyncCallback * obj -> IAsyncResult) * endAction: (IAsyncResult -> 'T) * ?cancelAction: (unit -> unit) -> Async<'T> + 3 overloads static member FromContinuations: callback: (('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T> ...
--------------------
type Async<'T>
static member Async.Sleep: dueTime: System.TimeSpan -> Async<unit>
static member Async.Sleep: millisecondsDueTime: int -> Async<unit>
static member Async.StartImmediateAsTask: computation: Async<'T> * ?cancellationToken: System.Threading.CancellationToken -> System.Threading.Tasks.Task<'T>
System.Threading.Tasks.Task.Wait() : unit
System.Threading.Tasks.Task.Wait(timeout: System.TimeSpan) : bool
System.Threading.Tasks.Task.Wait(cancellationToken: System.Threading.CancellationToken) : unit
System.Threading.Tasks.Task.Wait(millisecondsTimeout: int) : bool
System.Threading.Tasks.Task.Wait(timeout: System.TimeSpan, cancellationToken: System.Threading.CancellationToken) : bool
System.Threading.Tasks.Task.Wait(millisecondsTimeout: int, cancellationToken: System.Threading.CancellationToken) : bool
Async.StartWithContinuations(computation, continuation, exceptionContinuation, cancellationContinuation, ?cancellationToken)
Full Usage:
Async.StartWithContinuations(computation, continuation, exceptionContinuation, cancellationContinuation, ?cancellationToken)
Parameters:
Async<'T>
- The asynchronous computation to execute.
'T -> unit
- The function called on success.
exn -> unit
- The function called on exception.
OperationCanceledException -> unit
- The function called on cancellation.
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.
Async<'T>
The asynchronous computation to execute.
'T -> unit
The function called on success.
exn -> unit
The function called on exception.
OperationCanceledException -> unit
The function called on cancellation.
CancellationToken
The CancellationToken
to associate with the computation. The default is used if this parameter is not provided.
Full Usage:
Async.Choice(computations)
Parameters:
Async<'T option> seq
- A sequence of computations to be parallelized.
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.
Async<'T option> seq
A sequence of computations to be parallelized.
Async<'T option>
A computation that returns the first succeeding computation.
printfn "Starting"
let primes = [ 2; 3; 5; 7 ]
let computations =
[ for i in primes do
async {
do! Async.Sleep(System.Random().Next(1000, 2000))
return if i % 2 > 0 then Some(i) else None
}
]
computations
|> Async.Choice
|> Async.RunSynchronously
|> function
| Some (i) -> printfn $"{i}"
| None -> printfn "No Result"
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
val primes: int list
val computations: Async<int option> list
val i: int
val async: AsyncBuilder
Multiple items
type Async = static member AsBeginEnd: computation: ('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit) static member AwaitEvent: event: IEvent<'Del,'T> * ?cancelAction: (unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate) static member AwaitIAsyncResult: iar: IAsyncResult * ?millisecondsTimeout: int -> Async<bool> static member AwaitTask: task: Task<'T> -> Async<'T> + 1 overload static member AwaitWaitHandle: waitHandle: WaitHandle * ?millisecondsTimeout: int -> Async<bool> static member CancelDefaultToken: unit -> unit static member Catch: computation: Async<'T> -> Async<Choice<'T,exn>> static member Choice: computations: Async<'T option> seq -> Async<'T option> static member FromBeginEnd: beginAction: (AsyncCallback * obj -> IAsyncResult) * endAction: (IAsyncResult -> 'T) * ?cancelAction: (unit -> unit) -> Async<'T> + 3 overloads static member FromContinuations: callback: (('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T> ...
--------------------
type Async<'T>
static member Async.Sleep: dueTime: System.TimeSpan -> Async<unit>
static member Async.Sleep: millisecondsDueTime: int -> Async<unit>
namespace System
Multiple items
type Random = new: unit -> unit + 1 overload member GetHexString: stringLength: int * ?lowercase: bool -> string + 1 overload member GetItems<'T> : choices: ReadOnlySpan<'T> * length: int -> 'T array + 2 overloads member GetString: choices: ReadOnlySpan<char> * length: int -> string member Next: unit -> int + 2 overloads member NextBytes: buffer: byte array -> unit + 1 overload member NextDouble: unit -> float member NextInt64: unit -> int64 + 2 overloads member NextSingle: unit -> float32 member Shuffle<'T> : values: Span<'T> -> unit + 1 overload ...
--------------------
System.Random() : System.Random
System.Random(Seed: int) : System.Random
union case Option.Some: Value: 'T -> Option<'T>
union case Option.None: Option<'T>
static member Async.Choice: computations: Async<'T option> seq -> Async<'T option>
static member Async.RunSynchronously: computation: Async<'T> * ?timeout: int * ?cancellationToken: System.Threading.CancellationToken -> 'T
Prints one randomly selected odd number in 1-2 seconds. If the list is changed to all even numbers, it will instead print "No Result". let primes = [ 2; 3; 5; 7 ]
let computations =
[ for i in primes do
async {
do! Async.Sleep(System.Random().Next(1000, 2000))
return
if i % 2 > 0 then
Some(i)
else
failwith $"Even numbers not supported: {i}"
}
]
computations
|> Async.Choice
|> Async.RunSynchronously
|> function
| Some (i) -> printfn $"{i}"
| None -> printfn "No Result"
val primes: int list
val computations: Async<int option> list
val i: int
val async: AsyncBuilder
Multiple items
type Async = static member AsBeginEnd: computation: ('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit) static member AwaitEvent: event: IEvent<'Del,'T> * ?cancelAction: (unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate) static member AwaitIAsyncResult: iar: IAsyncResult * ?millisecondsTimeout: int -> Async<bool> static member AwaitTask: task: Task<'T> -> Async<'T> + 1 overload static member AwaitWaitHandle: waitHandle: WaitHandle * ?millisecondsTimeout: int -> Async<bool> static member CancelDefaultToken: unit -> unit static member Catch: computation: Async<'T> -> Async<Choice<'T,exn>> static member Choice: computations: Async<'T option> seq -> Async<'T option> static member FromBeginEnd: beginAction: (AsyncCallback * obj -> IAsyncResult) * endAction: (IAsyncResult -> 'T) * ?cancelAction: (unit -> unit) -> Async<'T> + 3 overloads static member FromContinuations: callback: (('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T> ...
--------------------
type Async<'T>
static member Async.Sleep: dueTime: System.TimeSpan -> Async<unit>
static member Async.Sleep: millisecondsDueTime: int -> Async<unit>
namespace System
Multiple items
type Random = new: unit -> unit + 1 overload member GetHexString: stringLength: int * ?lowercase: bool -> string + 1 overload member GetItems<'T> : choices: ReadOnlySpan<'T> * length: int -> 'T array + 2 overloads member GetString: choices: ReadOnlySpan<char> * length: int -> string member Next: unit -> int + 2 overloads member NextBytes: buffer: byte array -> unit + 1 overload member NextDouble: unit -> float member NextInt64: unit -> int64 + 2 overloads member NextSingle: unit -> float32 member Shuffle<'T> : values: Span<'T> -> unit + 1 overload ...
--------------------
System.Random() : System.Random
System.Random(Seed: int) : System.Random
union case Option.Some: Value: 'T -> Option<'T>
val failwith: message: string -> 'T
static member Async.Choice: computations: Async<'T option> seq -> Async<'T option>
static member Async.RunSynchronously: computation: Async<'T> * ?timeout: int * ?cancellationToken: System.Threading.CancellationToken -> 'T
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
union case Option.None: Option<'T>
Will sometimes print one randomly selected odd number, sometimes throw System.Exception("Even numbers not supported: 2").
Full Usage:
Async.FromContinuations(callback)
Parameters:
('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit
- The function that accepts the current success, exception, and cancellation continuations.
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.
('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit
The function that accepts the current success, exception, and cancellation continuations.
Async<'T>
An asynchronous computation that provides the callback with the current continuations.
let someRiskyBusiness() =
match DateTime.Today with
| dt when dt.DayOfWeek = DayOfWeek.Monday -> failwith "Not compatible with Mondays"
| dt -> dt
let computation =
(fun (successCont, exceptionCont, cancellationCont) ->
try
someRiskyBusiness () |> successCont
with
| :? OperationCanceledException as oce -> cancellationCont oce
| e -> exceptionCont e)
|> Async.FromContinuations
Async.StartWithContinuations(
computation,
(fun result -> printfn $"Result: {result}"),
(fun e -> printfn $"Exception: {e}"),
(fun oce -> printfn $"Cancelled: {oce}")
)
val someRiskyBusiness: unit -> 'a
val dt: obj
val failwith: message: string -> 'T
val computation: Async<obj>
val successCont: (obj -> unit)
val exceptionCont: (exn -> unit)
val cancellationCont: (System.OperationCanceledException -> unit)
val oce: System.OperationCanceledException
val oce: exn
val e: exn
Multiple items
type Async = static member AsBeginEnd: computation: ('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit) static member AwaitEvent: event: IEvent<'Del,'T> * ?cancelAction: (unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate) static member AwaitIAsyncResult: iar: IAsyncResult * ?millisecondsTimeout: int -> Async<bool> static member AwaitTask: task: Task<'T> -> Async<'T> + 1 overload static member AwaitWaitHandle: waitHandle: WaitHandle * ?millisecondsTimeout: int -> Async<bool> static member CancelDefaultToken: unit -> unit static member Catch: computation: Async<'T> -> Async<Choice<'T,exn>> static member Choice: computations: Async<'T option> seq -> Async<'T option> static member FromBeginEnd: beginAction: (AsyncCallback * obj -> IAsyncResult) * endAction: (IAsyncResult -> 'T) * ?cancelAction: (unit -> unit) -> Async<'T> + 3 overloads static member FromContinuations: callback: (('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T> ...
--------------------
type Async<'T>
static member Async.FromContinuations: callback: (('T -> unit) * (exn -> unit) * (System.OperationCanceledException -> unit) -> unit) -> Async<'T>
static member Async.StartWithContinuations: computation: Async<'T> * continuation: ('T -> unit) * exceptionContinuation: (exn -> unit) * cancellationContinuation: (System.OperationCanceledException -> unit) * ?cancellationToken: System.Threading.CancellationToken -> unit
val result: obj
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
This anonymous function will call someRiskyBusiness() and properly use the provided continuations defined to report the outcome.
Full Usage:
Async.Ignore(computation)
Parameters:
Async<'T>
- The input computation.
Async<unit>
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.
Async<'T>
The input computation.
Async<unit>
A computation that is equivalent to the input computation, but disregards the result.
let readFile filename numBytes =
async {
use file = System.IO.File.OpenRead(filename)
printfn "Reading from file %s." filename
// Throw away the data being read.
do! file.AsyncRead(numBytes) |> Async.Ignore
}
readFile "example.txt" 42 |> Async.Start
val readFile: filename: string -> numBytes: int -> Async<unit>
val filename: string
val numBytes: int
val async: AsyncBuilder
val file: System.IO.FileStream
namespace System
namespace System.IO
type File = static member AppendAllBytes: path: string * bytes: byte array -> unit + 1 overload static member AppendAllBytesAsync: path: string * bytes: byte array * ?cancellationToken: CancellationToken -> Task + 1 overload static member AppendAllLines: path: string * contents: IEnumerable<string> -> unit + 1 overload static member AppendAllLinesAsync: path: string * contents: IEnumerable<string> * encoding: Encoding * ?cancellationToken: CancellationToken -> Task + 1 overload static member AppendAllText: path: string * contents: ReadOnlySpan<char> -> unit + 3 overloads static member AppendAllTextAsync: path: string * contents: ReadOnlyMemory<char> * encoding: Encoding * ?cancellationToken: CancellationToken -> Task + 3 overloads static member AppendText: path: string -> StreamWriter static member Copy: sourceFileName: string * destFileName: string -> unit + 1 overload static member Create: path: string -> FileStream + 2 overloads static member CreateSymbolicLink: path: string * pathToTarget: string -> FileSystemInfo ...
<summary>Provides static methods for the creation, copying, deletion, moving, and opening of a single file, and aids in the creation of <see cref="T:System.IO.FileStream" /> objects.</summary>
System.IO.File.OpenRead(path: string) : System.IO.FileStream
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
member System.IO.Stream.AsyncRead: count: int -> Async<byte array>
member System.IO.Stream.AsyncRead: buffer: byte array * ?offset: int * ?count: int -> Async<int>
Multiple items
type Async = static member AsBeginEnd: computation: ('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit) static member AwaitEvent: event: IEvent<'Del,'T> * ?cancelAction: (unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate) static member AwaitIAsyncResult: iar: IAsyncResult * ?millisecondsTimeout: int -> Async<bool> static member AwaitTask: task: Task<'T> -> Async<'T> + 1 overload static member AwaitWaitHandle: waitHandle: WaitHandle * ?millisecondsTimeout: int -> Async<bool> static member CancelDefaultToken: unit -> unit static member Catch: computation: Async<'T> -> Async<Choice<'T,exn>> static member Choice: computations: Async<'T option> seq -> Async<'T option> static member FromBeginEnd: beginAction: (AsyncCallback * obj -> IAsyncResult) * endAction: (IAsyncResult -> 'T) * ?cancelAction: (unit -> unit) -> Async<'T> + 3 overloads static member FromContinuations: callback: (('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T> ...
--------------------
type Async<'T>
static member Async.Ignore: computation: Async<'T> -> Async<unit>
static member Async.Start: computation: Async<unit> * ?cancellationToken: System.Threading.CancellationToken -> unit
Reads bytes from a given file asynchronously and then ignores the result, allowing the do! to be used with functions that return an unwanted value.
Full Usage:
Async.Parallel(computations, ?maxDegreeOfParallelism)
Parameters:
Async<'T> seq
- A sequence of distinct computations to be parallelized.
int
- The maximum degree of parallelism in the parallel execution.
Async<'T array>
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.
Async<'T> seq
A sequence of distinct computations to be parallelized.
int
The maximum degree of parallelism in the parallel execution.
Async<'T array>
A computation that returns an array of values from the sequence of input computations.
let primes = [ 2; 3; 5; 7; 10; 11 ]
let computations =
[ for i in primes do
async {
do! Async.Sleep(System.Random().Next(1000, 2000))
return
if i % 2 > 0 then
printfn $"{i}"
true
else
false
} ]
let t =
Async.Parallel(computations, maxDegreeOfParallelism=3)
|> Async.StartAsTask
t.Wait()
printfn $"%A{t.Result}"
val primes: int list
val computations: Async<bool> list
val i: int
val async: AsyncBuilder
Multiple items
type Async = static member AsBeginEnd: computation: ('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit) static member AwaitEvent: event: IEvent<'Del,'T> * ?cancelAction: (unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate) static member AwaitIAsyncResult: iar: IAsyncResult * ?millisecondsTimeout: int -> Async<bool> static member AwaitTask: task: Task<'T> -> Async<'T> + 1 overload static member AwaitWaitHandle: waitHandle: WaitHandle * ?millisecondsTimeout: int -> Async<bool> static member CancelDefaultToken: unit -> unit static member Catch: computation: Async<'T> -> Async<Choice<'T,exn>> static member Choice: computations: Async<'T option> seq -> Async<'T option> static member FromBeginEnd: beginAction: (AsyncCallback * obj -> IAsyncResult) * endAction: (IAsyncResult -> 'T) * ?cancelAction: (unit -> unit) -> Async<'T> + 3 overloads static member FromContinuations: callback: (('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T> ...
--------------------
type Async<'T>
static member Async.Sleep: dueTime: System.TimeSpan -> Async<unit>
static member Async.Sleep: millisecondsDueTime: int -> Async<unit>
namespace System
Multiple items
type Random = new: unit -> unit + 1 overload member GetHexString: stringLength: int * ?lowercase: bool -> string + 1 overload member GetItems<'T> : choices: ReadOnlySpan<'T> * length: int -> 'T array + 2 overloads member GetString: choices: ReadOnlySpan<char> * length: int -> string member Next: unit -> int + 2 overloads member NextBytes: buffer: byte array -> unit + 1 overload member NextDouble: unit -> float member NextInt64: unit -> int64 + 2 overloads member NextSingle: unit -> float32 member Shuffle<'T> : values: Span<'T> -> unit + 1 overload ...
--------------------
System.Random() : System.Random
System.Random(Seed: int) : System.Random
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
val t: System.Threading.Tasks.Task<bool array>
static member Async.Parallel: computations: Async<'T> seq -> Async<'T array>
static member Async.Parallel: computations: Async<'T> seq * ?maxDegreeOfParallelism: int -> Async<'T array>
static member Async.StartAsTask: computation: Async<'T> * ?taskCreationOptions: System.Threading.Tasks.TaskCreationOptions * ?cancellationToken: System.Threading.CancellationToken -> System.Threading.Tasks.Task<'T>
System.Threading.Tasks.Task.Wait() : unit
System.Threading.Tasks.Task.Wait(timeout: System.TimeSpan) : bool
System.Threading.Tasks.Task.Wait(cancellationToken: System.Threading.CancellationToken) : unit
System.Threading.Tasks.Task.Wait(millisecondsTimeout: int) : bool
System.Threading.Tasks.Task.Wait(timeout: System.TimeSpan, cancellationToken: System.Threading.CancellationToken) : bool
System.Threading.Tasks.Task.Wait(millisecondsTimeout: int, cancellationToken: System.Threading.CancellationToken) : bool
property System.Threading.Tasks.Task.Result: bool array with get
This will print "3", "5" (in any order) in 1-2 seconds, and then "7", "11" (in any order) in 1-2 more seconds and then [| false; true; true; true; false; true |].
Full Usage:
Async.Parallel(computations)
Parameters:
Async<'T> seq
- A sequence of distinct computations to be parallelized.
Async<'T array>
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.
Async<'T> seq
A sequence of distinct computations to be parallelized.
Async<'T array>
A computation that returns an array of values from the sequence of input computations.
let primes = [ 2; 3; 5; 7; 10; 11 ]
let t =
[ for i in primes do
async {
do! Async.Sleep(System.Random().Next(1000, 2000))
if i % 2 > 0 then
printfn $"{i}"
return true
else
return false
}
]
|> Async.Parallel
|> Async.StartAsTask
t.Wait()
printfn $"%A{t.Result}"
val primes: int list
val t: System.Threading.Tasks.Task<bool array>
val i: int
val async: AsyncBuilder
Multiple items
type Async = static member AsBeginEnd: computation: ('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit) static member AwaitEvent: event: IEvent<'Del,'T> * ?cancelAction: (unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate) static member AwaitIAsyncResult: iar: IAsyncResult * ?millisecondsTimeout: int -> Async<bool> static member AwaitTask: task: Task<'T> -> Async<'T> + 1 overload static member AwaitWaitHandle: waitHandle: WaitHandle * ?millisecondsTimeout: int -> Async<bool> static member CancelDefaultToken: unit -> unit static member Catch: computation: Async<'T> -> Async<Choice<'T,exn>> static member Choice: computations: Async<'T option> seq -> Async<'T option> static member FromBeginEnd: beginAction: (AsyncCallback * obj -> IAsyncResult) * endAction: (IAsyncResult -> 'T) * ?cancelAction: (unit -> unit) -> Async<'T> + 3 overloads static member FromContinuations: callback: (('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T> ...
--------------------
type Async<'T>
static member Async.Sleep: dueTime: System.TimeSpan -> Async<unit>
static member Async.Sleep: millisecondsDueTime: int -> Async<unit>
namespace System
Multiple items
type Random = new: unit -> unit + 1 overload member GetHexString: stringLength: int * ?lowercase: bool -> string + 1 overload member GetItems<'T> : choices: ReadOnlySpan<'T> * length: int -> 'T array + 2 overloads member GetString: choices: ReadOnlySpan<char> * length: int -> string member Next: unit -> int + 2 overloads member NextBytes: buffer: byte array -> unit + 1 overload member NextDouble: unit -> float member NextInt64: unit -> int64 + 2 overloads member NextSingle: unit -> float32 member Shuffle<'T> : values: Span<'T> -> unit + 1 overload ...
--------------------
System.Random() : System.Random
System.Random(Seed: int) : System.Random
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
static member Async.Parallel: computations: Async<'T> seq -> Async<'T array>
static member Async.Parallel: computations: Async<'T> seq * ?maxDegreeOfParallelism: int -> Async<'T array>
static member Async.StartAsTask: computation: Async<'T> * ?taskCreationOptions: System.Threading.Tasks.TaskCreationOptions * ?cancellationToken: System.Threading.CancellationToken -> System.Threading.Tasks.Task<'T>
System.Threading.Tasks.Task.Wait() : unit
System.Threading.Tasks.Task.Wait(timeout: System.TimeSpan) : bool
System.Threading.Tasks.Task.Wait(cancellationToken: System.Threading.CancellationToken) : unit
System.Threading.Tasks.Task.Wait(millisecondsTimeout: int) : bool
System.Threading.Tasks.Task.Wait(timeout: System.TimeSpan, cancellationToken: System.Threading.CancellationToken) : bool
System.Threading.Tasks.Task.Wait(millisecondsTimeout: int, cancellationToken: System.Threading.CancellationToken) : bool
property System.Threading.Tasks.Task.Result: bool array with get
This will print "3", "5", "7", "11" (in any order) in 1-2 seconds and then [| false; true; true; true; false; true |].
Full Usage:
Async.Sequential(computations)
Parameters:
Async<'T> seq
- A sequence of distinct computations to be run in sequence.
Async<'T array>
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.
Async<'T> seq
A sequence of distinct computations to be run in sequence.
Async<'T array>
A computation that returns an array of values from the sequence of input computations.
let primes = [ 2; 3; 5; 7; 10; 11 ]
let computations =
[ for i in primes do
async {
do! Async.Sleep(System.Random().Next(1000, 2000))
if i % 2 > 0 then
printfn $"{i}"
return true
else
return false
}
]
let t =
Async.Sequential(computations)
|> Async.StartAsTask
t.Wait()
printfn $"%A{t.Result}"
val primes: int list
val computations: Async<bool> list
val i: int
val async: AsyncBuilder
Multiple items
type Async = static member AsBeginEnd: computation: ('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit) static member AwaitEvent: event: IEvent<'Del,'T> * ?cancelAction: (unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate) static member AwaitIAsyncResult: iar: IAsyncResult * ?millisecondsTimeout: int -> Async<bool> static member AwaitTask: task: Task<'T> -> Async<'T> + 1 overload static member AwaitWaitHandle: waitHandle: WaitHandle * ?millisecondsTimeout: int -> Async<bool> static member CancelDefaultToken: unit -> unit static member Catch: computation: Async<'T> -> Async<Choice<'T,exn>> static member Choice: computations: Async<'T option> seq -> Async<'T option> static member FromBeginEnd: beginAction: (AsyncCallback * obj -> IAsyncResult) * endAction: (IAsyncResult -> 'T) * ?cancelAction: (unit -> unit) -> Async<'T> + 3 overloads static member FromContinuations: callback: (('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T> ...
--------------------
type Async<'T>
static member Async.Sleep: dueTime: System.TimeSpan -> Async<unit>
static member Async.Sleep: millisecondsDueTime: int -> Async<unit>
namespace System
Multiple items
type Random = new: unit -> unit + 1 overload member GetHexString: stringLength: int * ?lowercase: bool -> string + 1 overload member GetItems<'T> : choices: ReadOnlySpan<'T> * length: int -> 'T array + 2 overloads member GetString: choices: ReadOnlySpan<char> * length: int -> string member Next: unit -> int + 2 overloads member NextBytes: buffer: byte array -> unit + 1 overload member NextDouble: unit -> float member NextInt64: unit -> int64 + 2 overloads member NextSingle: unit -> float32 member Shuffle<'T> : values: Span<'T> -> unit + 1 overload ...
--------------------
System.Random() : System.Random
System.Random(Seed: int) : System.Random
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
val t: System.Threading.Tasks.Task<bool array>
static member Async.Sequential: computations: Async<'T> seq -> Async<'T array>
static member Async.StartAsTask: computation: Async<'T> * ?taskCreationOptions: System.Threading.Tasks.TaskCreationOptions * ?cancellationToken: System.Threading.CancellationToken -> System.Threading.Tasks.Task<'T>
System.Threading.Tasks.Task.Wait() : unit
System.Threading.Tasks.Task.Wait(timeout: System.TimeSpan) : bool
System.Threading.Tasks.Task.Wait(cancellationToken: System.Threading.CancellationToken) : unit
System.Threading.Tasks.Task.Wait(millisecondsTimeout: int) : bool
System.Threading.Tasks.Task.Wait(timeout: System.TimeSpan, cancellationToken: System.Threading.CancellationToken) : bool
System.Threading.Tasks.Task.Wait(millisecondsTimeout: int, cancellationToken: System.Threading.CancellationToken) : bool
property System.Threading.Tasks.Task.Result: bool array with get
This will print "3", "5", "7", "11" with ~1-2 seconds between them except for pauses where even numbers would be and then prints [| false; true; true; true; false; true |]. Awaiting Results Static members
Full Usage:
Async.AwaitEvent(event, ?cancelAction)
Parameters:
IEvent<'Del, 'T>
- The event to handle once.
unit -> unit
- An optional function to execute instead of cancelling when a cancellation is issued.
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.
IEvent<'Del, 'T>
The event to handle once.
unit -> unit
An optional function to execute instead of cancelling when a cancellation is issued.
Async<'T>
An asynchronous computation that waits for the event to be invoked.
Full Usage:
Async.AwaitIAsyncResult(iar, ?millisecondsTimeout)
Parameters:
IAsyncResult
- The IAsyncResult to wait on.
int
- The timeout value in milliseconds. If one is not provided then the default value of -1 corresponding to Timeout.Infinite.
Async<bool>
An asynchronous computation that waits on the given
IAsyncResult
.
Creates an asynchronous computation that will wait on the IAsyncResult.
IAsyncResult
The IAsyncResult to wait on.
int
The timeout value in milliseconds. If one is not provided then the default value of -1 corresponding to Timeout.Infinite.
Async<bool>
An asynchronous computation that waits on the given IAsyncResult
.
Full Usage:
Async.AwaitTask(task)
Parameters:
Task
- The task to await.
Async<unit>
Return an asynchronous computation that will wait for the given task to complete and return its result.
Task
The task to await.
Async<unit>
Full Usage:
Async.AwaitTask(task)
Parameters:
Task<'T>
- The task to await.
Async<'T>
Return an asynchronous computation that will wait for the given task to complete and return its result.
Task<'T>
The task to await.
Async<'T>
Full Usage:
Async.AwaitWaitHandle(waitHandle, ?millisecondsTimeout)
Parameters:
WaitHandle
- The WaitHandle
that can be signalled.
int
- The timeout value in milliseconds. If one is not provided then the default value of -1 corresponding to Timeout.Infinite.
Async<bool>
An asynchronous computation that waits on the given
WaitHandle
.
Creates an asynchronous computation that will wait on the given WaitHandle.
WaitHandle
The WaitHandle
that can be signalled.
int
The timeout value in milliseconds. If one is not provided then the default value of -1 corresponding to Timeout.Infinite.
Async<bool>
An asynchronous computation that waits on the given WaitHandle
.
Full Usage:
Async.Sleep(dueTime)
Parameters:
TimeSpan
- The amount of time to sleep.
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.
TimeSpan
The amount of time to sleep.
Async<unit>
An asynchronous computation that will sleep for the given time.
async {
printfn "A"
do! Async.Sleep(TimeSpan(0, 0, 1))
printfn "B"
} |> Async.Start
printfn "C"
val async: AsyncBuilder
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
Multiple items
type Async = static member AsBeginEnd: computation: ('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit) static member AwaitEvent: event: IEvent<'Del,'T> * ?cancelAction: (unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate) static member AwaitIAsyncResult: iar: IAsyncResult * ?millisecondsTimeout: int -> Async<bool> static member AwaitTask: task: Task<'T> -> Async<'T> + 1 overload static member AwaitWaitHandle: waitHandle: WaitHandle * ?millisecondsTimeout: int -> Async<bool> static member CancelDefaultToken: unit -> unit static member Catch: computation: Async<'T> -> Async<Choice<'T,exn>> static member Choice: computations: Async<'T option> seq -> Async<'T option> static member FromBeginEnd: beginAction: (AsyncCallback * obj -> IAsyncResult) * endAction: (IAsyncResult -> 'T) * ?cancelAction: (unit -> unit) -> Async<'T> + 3 overloads static member FromContinuations: callback: (('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T> ...
--------------------
type Async<'T>
static member Async.Sleep: dueTime: System.TimeSpan -> Async<unit>
static member Async.Sleep: millisecondsDueTime: int -> Async<unit>
static member Async.Start: computation: Async<unit> * ?cancellationToken: System.Threading.CancellationToken -> unit
Prints "C", then "A" quickly, and then "B" 1 second later.
Full Usage:
Async.Sleep(millisecondsDueTime)
Parameters:
int
- The number of milliseconds to sleep.
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.
int
The number of milliseconds to sleep.
Async<unit>
An asynchronous computation that will sleep for the given time.
async {
printfn "A"
do! Async.Sleep(1000)
printfn "B"
} |> Async.Start
printfn "C"
val async: AsyncBuilder
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
Multiple items
type Async = static member AsBeginEnd: computation: ('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit) static member AwaitEvent: event: IEvent<'Del,'T> * ?cancelAction: (unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate) static member AwaitIAsyncResult: iar: IAsyncResult * ?millisecondsTimeout: int -> Async<bool> static member AwaitTask: task: Task<'T> -> Async<'T> + 1 overload static member AwaitWaitHandle: waitHandle: WaitHandle * ?millisecondsTimeout: int -> Async<bool> static member CancelDefaultToken: unit -> unit static member Catch: computation: Async<'T> -> Async<Choice<'T,exn>> static member Choice: computations: Async<'T option> seq -> Async<'T option> static member FromBeginEnd: beginAction: (AsyncCallback * obj -> IAsyncResult) * endAction: (IAsyncResult -> 'T) * ?cancelAction: (unit -> unit) -> Async<'T> + 3 overloads static member FromContinuations: callback: (('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T> ...
--------------------
type Async<'T>
static member Async.Sleep: dueTime: System.TimeSpan -> Async<unit>
static member Async.Sleep: millisecondsDueTime: int -> Async<unit>
static member Async.Start: computation: Async<unit> * ?cancellationToken: System.Threading.CancellationToken -> unit
Prints "C" and "A" quickly in any order, and then "B" 1 second later Cancellation and Exceptions Static members
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.
let primes = [ 2; 3; 5; 7; 11 ]
let computations =
[ for i in primes do
async {
do! Async.Sleep(i * 1000)
printfn $"{i}"
}
]
try
let t =
Async.Parallel(computations, 3) |> Async.StartAsTask
Thread.Sleep(6000)
Async.CancelDefaultToken()
printfn $"Tasks Finished: %A{t.Result}"
with
| :? System.AggregateException as ae -> printfn $"Tasks Not Finished: {ae.Message}"
val primes: int list
val computations: Async<unit> list
val i: int
val async: AsyncBuilder
Multiple items
type Async = static member AsBeginEnd: computation: ('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit) static member AwaitEvent: event: IEvent<'Del,'T> * ?cancelAction: (unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate) static member AwaitIAsyncResult: iar: IAsyncResult * ?millisecondsTimeout: int -> Async<bool> static member AwaitTask: task: Task<'T> -> Async<'T> + 1 overload static member AwaitWaitHandle: waitHandle: WaitHandle * ?millisecondsTimeout: int -> Async<bool> static member CancelDefaultToken: unit -> unit static member Catch: computation: Async<'T> -> Async<Choice<'T,exn>> static member Choice: computations: Async<'T option> seq -> Async<'T option> static member FromBeginEnd: beginAction: (AsyncCallback * obj -> IAsyncResult) * endAction: (IAsyncResult -> 'T) * ?cancelAction: (unit -> unit) -> Async<'T> + 3 overloads static member FromContinuations: callback: (('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T> ...
--------------------
type Async<'T>
static member Async.Sleep: dueTime: System.TimeSpan -> Async<unit>
static member Async.Sleep: millisecondsDueTime: int -> Async<unit>
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
val t: System.Threading.Tasks.Task<unit array>
static member Async.Parallel: computations: Async<'T> seq -> Async<'T array>
static member Async.Parallel: computations: Async<'T> seq * ?maxDegreeOfParallelism: int -> Async<'T array>
static member Async.StartAsTask: computation: Async<'T> * ?taskCreationOptions: System.Threading.Tasks.TaskCreationOptions * ?cancellationToken: System.Threading.CancellationToken -> System.Threading.Tasks.Task<'T>
static member Async.CancelDefaultToken: unit -> unit
property System.Threading.Tasks.Task.Result: unit array with get
namespace System
Multiple items
type AggregateException = inherit exn new: unit -> unit + 6 overloads member Flatten: unit -> AggregateException member GetBaseException: unit -> exn member GetObjectData: info: SerializationInfo * context: StreamingContext -> unit member Handle: predicate: Func<exn,bool> -> unit member ToString: unit -> string member InnerExceptions: ReadOnlyCollection<exn> member Message: string
--------------------
System.AggregateException() : System.AggregateException
System.AggregateException(innerExceptions: System.Collections.Generic.IEnumerable<exn>) : System.AggregateException
System.AggregateException([<System.ParamArray>] innerExceptions: exn array) : System.AggregateException
System.AggregateException(message: string) : System.AggregateException
System.AggregateException(message: string, innerExceptions: System.Collections.Generic.IEnumerable<exn>) : System.AggregateException
System.AggregateException(message: string, innerException: exn) : System.AggregateException
System.AggregateException(message: string, [<System.ParamArray>] innerExceptions: exn array) : System.AggregateException
val ae: System.AggregateException
property System.AggregateException.Message: string with get
<summary>Gets a message that describes the exception.</summary>
<returns>The message that describes the exception.</returns>
Full Usage:
Async.CancellationToken
Returns: Async<CancellationToken>
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.
Async<CancellationToken>
An asynchronous computation capable of retrieving the CancellationToken from a computation expression.
Full Usage:
Async.Catch(computation)
Parameters:
Async<'T>
- The input computation that returns the type T.
Async<Choice<'T, exn>>
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.
Async<'T>
The input computation that returns the type T.
Async<Choice<'T, exn>>
A computation that returns a choice of type T or exception.
let someRiskyBusiness() =
match DateTime.Today with
| dt when dt.DayOfWeek = DayOfWeek.Monday -> failwith "Not compatible with Mondays"
| dt -> dt
async { return someRiskyBusiness() }
|> Async.Catch
|> Async.RunSynchronously
|> function
| Choice1Of2 result -> printfn $"Result: {result}"
| Choice2Of2 e -> printfn $"Exception: {e}"
val someRiskyBusiness: unit -> 'a
val dt: obj
val failwith: message: string -> 'T
val async: AsyncBuilder
Multiple items
type Async = static member AsBeginEnd: computation: ('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit) static member AwaitEvent: event: IEvent<'Del,'T> * ?cancelAction: (unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate) static member AwaitIAsyncResult: iar: IAsyncResult * ?millisecondsTimeout: int -> Async<bool> static member AwaitTask: task: Task<'T> -> Async<'T> + 1 overload static member AwaitWaitHandle: waitHandle: WaitHandle * ?millisecondsTimeout: int -> Async<bool> static member CancelDefaultToken: unit -> unit static member Catch: computation: Async<'T> -> Async<Choice<'T,exn>> static member Choice: computations: Async<'T option> seq -> Async<'T option> static member FromBeginEnd: beginAction: (AsyncCallback * obj -> IAsyncResult) * endAction: (IAsyncResult -> 'T) * ?cancelAction: (unit -> unit) -> Async<'T> + 3 overloads static member FromContinuations: callback: (('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T> ...
--------------------
type Async<'T>
static member Async.Catch: computation: Async<'T> -> Async<Choice<'T,exn>>
static member Async.RunSynchronously: computation: Async<'T> * ?timeout: int * ?cancellationToken: System.Threading.CancellationToken -> 'T
union case Choice.Choice1Of2: 'T1 -> Choice<'T1,'T2>
val result: obj
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
union case Choice.Choice2Of2: 'T2 -> Choice<'T1,'T2>
val e: exn
Prints the returned value of someRiskyBusiness() or the exception if there is one.
Full Usage:
Async.DefaultCancellationToken
Returns: CancellationToken
The default CancellationToken.
Gets the default cancellation token for executing asynchronous computations.
CancellationToken
The default CancellationToken.
Async.DefaultCancellationToken.Register(fun () -> printfn "Computation Cancelled") |> ignore
let primes = [ 2; 3; 5; 7; 11 ]
for i in primes do
async {
do! Async.Sleep(i * 1000)
printfn $"{i}"
}
|> Async.Start
Thread.Sleep(6000)
Async.CancelDefaultToken()
printfn "Tasks Finished"
Multiple items
type Async = static member AsBeginEnd: computation: ('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit) static member AwaitEvent: event: IEvent<'Del,'T> * ?cancelAction: (unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate) static member AwaitIAsyncResult: iar: IAsyncResult * ?millisecondsTimeout: int -> Async<bool> static member AwaitTask: task: Task<'T> -> Async<'T> + 1 overload static member AwaitWaitHandle: waitHandle: WaitHandle * ?millisecondsTimeout: int -> Async<bool> static member CancelDefaultToken: unit -> unit static member Catch: computation: Async<'T> -> Async<Choice<'T,exn>> static member Choice: computations: Async<'T option> seq -> Async<'T option> static member FromBeginEnd: beginAction: (AsyncCallback * obj -> IAsyncResult) * endAction: (IAsyncResult -> 'T) * ?cancelAction: (unit -> unit) -> Async<'T> + 3 overloads static member FromContinuations: callback: (('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T> ...
--------------------
type Async<'T>
property Async.DefaultCancellationToken: System.Threading.CancellationToken with get
System.Threading.CancellationToken.Register(callback: System.Action) : System.Threading.CancellationTokenRegistration
System.Threading.CancellationToken.Register(callback: System.Action<obj>, state: obj) : System.Threading.CancellationTokenRegistration
System.Threading.CancellationToken.Register(callback: System.Action<obj,System.Threading.CancellationToken>, state: obj) : System.Threading.CancellationTokenRegistration
System.Threading.CancellationToken.Register(callback: System.Action, useSynchronizationContext: bool) : System.Threading.CancellationTokenRegistration
System.Threading.CancellationToken.Register(callback: System.Action<obj>, state: obj, useSynchronizationContext: bool) : System.Threading.CancellationTokenRegistration
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
val ignore: value: 'T -> unit
val primes: int list
val i: int
val async: AsyncBuilder
static member Async.Sleep: dueTime: System.TimeSpan -> Async<unit>
static member Async.Sleep: millisecondsDueTime: int -> Async<unit>
static member Async.Start: computation: Async<unit> * ?cancellationToken: System.Threading.CancellationToken -> unit
static member Async.CancelDefaultToken: unit -> unit
This will print "2" 2 seconds from start, "3" 3 seconds from start, "5" 5 seconds from start, cease computation and then print "Computation Cancelled", followed by "Tasks Finished".
Full Usage:
Async.OnCancel(interruption)
Parameters:
unit -> unit
- The function that is executed on the thread performing the cancellation.
Async<IDisposable>
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.
unit -> unit
The function that is executed on the thread performing the cancellation.
Async<IDisposable>
An asynchronous computation that triggers the interruption if it is cancelled before being disposed.
let primes = [ 2; 3; 5; 7; 11 ]
for i in primes do
async {
use! holder = Async.OnCancel(fun () -> printfn $"Computation Cancelled: {i}")
do! Async.Sleep(i * 1000)
printfn $"{i}"
}
|> Async.Start
Thread.Sleep(6000)
Async.CancelDefaultToken()
printfn "Tasks Finished"
val primes: int list
val i: int
val async: AsyncBuilder
val holder: System.IDisposable
Multiple items
type Async = static member AsBeginEnd: computation: ('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit) static member AwaitEvent: event: IEvent<'Del,'T> * ?cancelAction: (unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate) static member AwaitIAsyncResult: iar: IAsyncResult * ?millisecondsTimeout: int -> Async<bool> static member AwaitTask: task: Task<'T> -> Async<'T> + 1 overload static member AwaitWaitHandle: waitHandle: WaitHandle * ?millisecondsTimeout: int -> Async<bool> static member CancelDefaultToken: unit -> unit static member Catch: computation: Async<'T> -> Async<Choice<'T,exn>> static member Choice: computations: Async<'T option> seq -> Async<'T option> static member FromBeginEnd: beginAction: (AsyncCallback * obj -> IAsyncResult) * endAction: (IAsyncResult -> 'T) * ?cancelAction: (unit -> unit) -> Async<'T> + 3 overloads static member FromContinuations: callback: (('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T> ...
--------------------
type Async<'T>
static member Async.OnCancel: interruption: (unit -> unit) -> Async<System.IDisposable>
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
static member Async.Sleep: dueTime: System.TimeSpan -> Async<unit>
static member Async.Sleep: millisecondsDueTime: int -> Async<unit>
static member Async.Start: computation: Async<unit> * ?cancellationToken: System.Threading.CancellationToken -> unit
static member Async.CancelDefaultToken: unit -> unit
This will print "2" 2 seconds from start, "3" 3 seconds from start, "5" 5 seconds from start, cease computation and then print "Computation Cancelled: 7", "Computation Cancelled: 11" and "Tasks Finished" in any order.
Full Usage:
Async.StartChild(computation, ?millisecondsTimeout)
Parameters:
Async<'T>
- The child computation.
int
- The timeout value in milliseconds. If one is not provided then the default value of -1 corresponding to Timeout.Infinite.
Async<Async<'T>>
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.
async { ...
let! completor1 = childComputation1 |> Async.StartChild
let! completor2 = childComputation2 |> Async.StartChild
...
let! result1 = completor1
let! result2 = completor2
... }
val async: AsyncBuilder
Multiple items
type Async = static member AsBeginEnd: computation: ('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit) static member AwaitEvent: event: IEvent<'Del,'T> * ?cancelAction: (unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate) static member AwaitIAsyncResult: iar: IAsyncResult * ?millisecondsTimeout: int -> Async<bool> static member AwaitTask: task: Task<'T> -> Async<'T> + 1 overload static member AwaitWaitHandle: waitHandle: WaitHandle * ?millisecondsTimeout: int -> Async<bool> static member CancelDefaultToken: unit -> unit static member Catch: computation: Async<'T> -> Async<Choice<'T,exn>> static member Choice: computations: Async<'T option> seq -> Async<'T option> static member FromBeginEnd: beginAction: (AsyncCallback * obj -> IAsyncResult) * endAction: (IAsyncResult -> 'T) * ?cancelAction: (unit -> unit) -> Async<'T> + 3 overloads static member FromContinuations: callback: (('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T> ...
--------------------
type Async<'T>
static member Async.StartChild: computation: Async<'T> * ?millisecondsTimeout: int -> Async<Async<'T>>
When used in this way, each use ofStartChild
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
.
Async<'T>
The child computation.
int
The timeout value in milliseconds. If one is not provided then the default value of -1 corresponding to Timeout.Infinite.
Async<Async<'T>>
A new computation that waits for the input computation to finish.
let computeWithTimeout timeout =
async {
let! completor1 =
Async.StartChild(
(async {
do! Async.Sleep(1000)
return 1
}),
millisecondsTimeout = timeout)
let! completor2 =
Async.StartChild(
(async {
do! Async.Sleep(2000)
return 2
}),
millisecondsTimeout = timeout)
let! v1 = completor1
let! v2 = completor2
printfn $"Result: {v1 + v2}"
} |> Async.RunSynchronously
val computeWithTimeout: timeout: int -> unit
val timeout: int
val async: AsyncBuilder
val completor1: Async<int>
Multiple items
type Async = static member AsBeginEnd: computation: ('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit) static member AwaitEvent: event: IEvent<'Del,'T> * ?cancelAction: (unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate) static member AwaitIAsyncResult: iar: IAsyncResult * ?millisecondsTimeout: int -> Async<bool> static member AwaitTask: task: Task<'T> -> Async<'T> + 1 overload static member AwaitWaitHandle: waitHandle: WaitHandle * ?millisecondsTimeout: int -> Async<bool> static member CancelDefaultToken: unit -> unit static member Catch: computation: Async<'T> -> Async<Choice<'T,exn>> static member Choice: computations: Async<'T option> seq -> Async<'T option> static member FromBeginEnd: beginAction: (AsyncCallback * obj -> IAsyncResult) * endAction: (IAsyncResult -> 'T) * ?cancelAction: (unit -> unit) -> Async<'T> + 3 overloads static member FromContinuations: callback: (('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T> ...
--------------------
type Async<'T>
static member Async.StartChild: computation: Async<'T> * ?millisecondsTimeout: int -> Async<Async<'T>>
static member Async.Sleep: dueTime: System.TimeSpan -> Async<unit>
static member Async.Sleep: millisecondsDueTime: int -> Async<unit>
val completor2: Async<int>
val v1: int
val v2: int
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
static member Async.RunSynchronously: computation: Async<'T> * ?timeout: int * ?cancellationToken: System.Threading.CancellationToken -> 'T
Will throw a System.TimeoutException if called with a timeout less than 2000, otherwise will print "Result: 3".
Full Usage:
Async.TryCancelled(computation, compensation)
Parameters:
Async<'T>
- The input asynchronous computation.
OperationCanceledException -> unit
- The function to be run if the computation is cancelled.
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.
Async<'T>
The input asynchronous computation.
OperationCanceledException -> unit
The function to be run if the computation is cancelled.
Async<'T>
An asynchronous computation that runs the compensation if the input computation is cancelled.
let primes = [ 2; 3; 5; 7; 11 ]
for i in primes do
Async.TryCancelled(
async {
do! Async.Sleep(i * 1000)
printfn $"{i}"
},
fun oce -> printfn $"Computation Cancelled: {i}")
|> Async.Start
Thread.Sleep(6000)
Async.CancelDefaultToken()
printfn "Tasks Finished"
val primes: int list
val i: int
Multiple items
type Async = static member AsBeginEnd: computation: ('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit) static member AwaitEvent: event: IEvent<'Del,'T> * ?cancelAction: (unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate) static member AwaitIAsyncResult: iar: IAsyncResult * ?millisecondsTimeout: int -> Async<bool> static member AwaitTask: task: Task<'T> -> Async<'T> + 1 overload static member AwaitWaitHandle: waitHandle: WaitHandle * ?millisecondsTimeout: int -> Async<bool> static member CancelDefaultToken: unit -> unit static member Catch: computation: Async<'T> -> Async<Choice<'T,exn>> static member Choice: computations: Async<'T option> seq -> Async<'T option> static member FromBeginEnd: beginAction: (AsyncCallback * obj -> IAsyncResult) * endAction: (IAsyncResult -> 'T) * ?cancelAction: (unit -> unit) -> Async<'T> + 3 overloads static member FromContinuations: callback: (('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T> ...
--------------------
type Async<'T>
static member Async.TryCancelled: computation: Async<'T> * compensation: (System.OperationCanceledException -> unit) -> Async<'T>
val async: AsyncBuilder
static member Async.Sleep: dueTime: System.TimeSpan -> Async<unit>
static member Async.Sleep: millisecondsDueTime: int -> Async<unit>
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
val oce: System.OperationCanceledException
static member Async.Start: computation: Async<unit> * ?cancellationToken: System.Threading.CancellationToken -> unit
static member Async.CancelDefaultToken: unit -> unit
This will print "2" 2 seconds from start, "3" 3 seconds from start, "5" 5 seconds from start, cease computation and then print "Computation Cancelled: 7", "Computation Cancelled: 11" and "Tasks Finished" in any order. Threads and Contexts Static members
Full Usage:
Async.SwitchToContext(syncContext)
Parameters:
SynchronizationContext
- The synchronization context to accept the posted computation.
Async<unit>
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().
SynchronizationContext
The synchronization context to accept the posted computation.
Async<unit>
An asynchronous computation that uses the syncContext context to execute.
Full Usage:
Async.SwitchToNewThread()
Returns: Async<unit>
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.
Async<unit>
A computation that will execute on a new thread.
async {
do! Async.SwitchToNewThread()
do! someLongRunningComputation()
} |> Async.StartImmediate
val async: AsyncBuilder
Multiple items
type Async = static member AsBeginEnd: computation: ('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit) static member AwaitEvent: event: IEvent<'Del,'T> * ?cancelAction: (unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate) static member AwaitIAsyncResult: iar: IAsyncResult * ?millisecondsTimeout: int -> Async<bool> static member AwaitTask: task: Task<'T> -> Async<'T> + 1 overload static member AwaitWaitHandle: waitHandle: WaitHandle * ?millisecondsTimeout: int -> Async<bool> static member CancelDefaultToken: unit -> unit static member Catch: computation: Async<'T> -> Async<Choice<'T,exn>> static member Choice: computations: Async<'T option> seq -> Async<'T option> static member FromBeginEnd: beginAction: (AsyncCallback * obj -> IAsyncResult) * endAction: (IAsyncResult -> 'T) * ?cancelAction: (unit -> unit) -> Async<'T> + 3 overloads static member FromContinuations: callback: (('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T> ...
--------------------
type Async<'T>
static member Async.SwitchToNewThread: unit -> Async<unit>
static member Async.StartImmediate: computation: Async<unit> * ?cancellationToken: System.Threading.CancellationToken -> unit
This will run someLongRunningComputation() without blocking the threads in the threadpool.
Full Usage:
Async.SwitchToThreadPool()
Returns: Async<unit>
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.
Async<unit>
A computation that generates a new work item in the thread pool.
async {
do! Async.SwitchToNewThread()
do! someLongRunningComputation()
do! Async.SwitchToThreadPool()
for i in 1 .. 10 do
do! someShortRunningComputation()
} |> Async.StartImmediate
val async: AsyncBuilder
Multiple items
type Async = static member AsBeginEnd: computation: ('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit) static member AwaitEvent: event: IEvent<'Del,'T> * ?cancelAction: (unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate) static member AwaitIAsyncResult: iar: IAsyncResult * ?millisecondsTimeout: int -> Async<bool> static member AwaitTask: task: Task<'T> -> Async<'T> + 1 overload static member AwaitWaitHandle: waitHandle: WaitHandle * ?millisecondsTimeout: int -> Async<bool> static member CancelDefaultToken: unit -> unit static member Catch: computation: Async<'T> -> Async<Choice<'T,exn>> static member Choice: computations: Async<'T option> seq -> Async<'T option> static member FromBeginEnd: beginAction: (AsyncCallback * obj -> IAsyncResult) * endAction: (IAsyncResult -> 'T) * ?cancelAction: (unit -> unit) -> Async<'T> + 3 overloads static member FromContinuations: callback: (('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T> ...
--------------------
type Async<'T>
static member Async.SwitchToNewThread: unit -> Async<unit>
static member Async.SwitchToThreadPool: unit -> Async<unit>
val i: int
static member Async.StartImmediate: computation: Async<unit> * ?cancellationToken: System.Threading.CancellationToken -> unit
This will run someLongRunningComputation() without blocking the threads in the threadpool, and then switch to the threadpool for shorter computations. Legacy .NET Async Interoperability Static members
Full Usage:
Async.AsBeginEnd(computation)
Parameters:
'Arg -> Async<'T>
- A function generating the asynchronous computation to split into the traditional .NET Asynchronous Programming Model.
('Arg * AsyncCallback * objnull -> 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.
'Arg -> Async<'T>
A function generating the asynchronous computation to split into the traditional .NET Asynchronous Programming Model.
('Arg * AsyncCallback * objnull -> 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
- The first argument for the operation.
'Arg2
- The second argument for the operation.
'Arg3
- The third argument for the operation.
'Arg1 * 'Arg2 * 'Arg3 * AsyncCallback * objnull -> IAsyncResult
- The function initiating a traditional CLI asynchronous operation.
IAsyncResult -> 'T
- The function completing a traditional CLI asynchronous operation.
unit -> unit
- An optional function to be executed when a cancellation is requested.
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.
'Arg1
The first argument for the operation.
'Arg2
The second argument for the operation.
'Arg3
The third argument for the operation.
'Arg1 * 'Arg2 * 'Arg3 * AsyncCallback * objnull -> IAsyncResult
The function initiating a traditional CLI asynchronous operation.
IAsyncResult -> 'T
The function completing a traditional CLI asynchronous operation.
unit -> unit
An optional function to be executed when a cancellation is requested.
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
- The first argument for the operation.
'Arg2
- The second argument for the operation.
'Arg1 * 'Arg2 * AsyncCallback * objnull -> IAsyncResult
- The function initiating a traditional CLI asynchronous operation.
IAsyncResult -> 'T
- The function completing a traditional CLI asynchronous operation.
unit -> unit
- An optional function to be executed when a cancellation is requested.
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.
'Arg1
The first argument for the operation.
'Arg2
The second argument for the operation.
'Arg1 * 'Arg2 * AsyncCallback * objnull -> IAsyncResult
The function initiating a traditional CLI asynchronous operation.
IAsyncResult -> 'T
The function completing a traditional CLI asynchronous operation.
unit -> unit
An optional function to be executed when a cancellation is requested.
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:
'Arg1
- The argument for the operation.
'Arg1 * AsyncCallback * objnull -> IAsyncResult
- The function initiating a traditional CLI asynchronous operation.
IAsyncResult -> 'T
- The function completing a traditional CLI asynchronous operation.
unit -> unit
- An optional function to be executed when a cancellation is requested.
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.
'Arg1
The argument for the operation.
'Arg1 * AsyncCallback * objnull -> IAsyncResult
The function initiating a traditional CLI asynchronous operation.
IAsyncResult -> 'T
The function completing a traditional CLI asynchronous operation.
unit -> unit
An optional function to be executed when a cancellation is requested.
Async<'T>
An asynchronous computation wrapping the given Begin/End functions.
Full Usage:
Async.FromBeginEnd(beginAction, endAction, ?cancelAction)
Parameters:
AsyncCallback * objnull -> IAsyncResult
- The function initiating a traditional CLI asynchronous operation.
IAsyncResult -> 'T
- The function completing a traditional CLI asynchronous operation.
unit -> unit
- An optional function to be executed when a cancellation is requested.
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.
AsyncCallback * objnull -> IAsyncResult
The function initiating a traditional CLI asynchronous operation.
IAsyncResult -> 'T
The function completing a traditional CLI asynchronous operation.
unit -> unit
An optional function to be executed when a cancellation is requested.
Async<'T>
An asynchronous computation wrapping the given Begin/End functions.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4