MailboxProcessor<'Msg> Type
A message-processing agent which executes an asynchronous computation.
The agent encapsulates a message queue that supports multiple-writers and a single reader agent. Writers send messages to the agent by using the Post method and its variations. The agent may wait for messages using the Receive or TryReceive methods or scan through all available messages using the Scan or TryScan method.
Constructors
Constructor |
Description
|
Full Usage:
MailboxProcessor(body, isThrowExceptionAfterDisposed, ?cancellationToken)
Parameters:
MailboxProcessor<'Msg> -> Async<unit>
-
The function to produce an asynchronous computation that will be executed
as the read loop for the MailboxProcessor when Start is called.
isThrowExceptionAfterDisposed : bool
-
A flag denoting that an exception will be thrown
when MailboxProcessor.Post is called
after Control.MailboxProcessor has been disposed.
?cancellationToken : CancellationToken
-
An optional cancellation token for the body .
Defaults to Async.DefaultCancellationToken .
Returns: MailboxProcessor<'Msg>
The created MailboxProcessor.
|
Creates an agent. The
|
Full Usage:
MailboxProcessor(body, ?cancellationToken)
Parameters:
MailboxProcessor<'Msg> -> Async<unit>
-
The function to produce an asynchronous computation that will be executed
as the read loop for the MailboxProcessor when Start is called.
?cancellationToken : CancellationToken
-
An optional cancellation token for the body .
Defaults to Async.DefaultCancellationToken .
Returns: MailboxProcessor<'Msg>
The created MailboxProcessor.
|
Creates an agent. The
|
Instance members
Instance member |
Description
|
||
|
Returns the number of unprocessed messages in the message queue of the agent.
|
||
Full Usage:
this.DefaultTimeout
|
Raises a timeout exception if a message not received in this amount of time. By default no timeout is used. |
||
Full Usage:
this.Dispose
|
Disposes the agent's internal resources. |
||
|
|||
Full Usage:
this.Post
Parameters:
'Msg
-
The message to post.
|
Posts a message to the message queue of the MailboxProcessor, asynchronously.
|
||
Full Usage:
this.PostAndAsyncReply
Parameters:
AsyncReplyChannel<'Reply> -> 'Msg
-
The function to incorporate the AsyncReplyChannel into
the message to be sent.
?timeout : int
-
An optional timeout parameter (in milliseconds) to wait for a reply message.
Defaults to -1 which corresponds to Timeout.Infinite.
Returns: Async<'Reply>
An asynchronous computation that will wait for the reply from the agent.
|
Posts a message to an agent and await a reply on the channel, asynchronously.
The message is generated by applying
|
||
Full Usage:
this.PostAndReply
Parameters:
AsyncReplyChannel<'Reply> -> 'Msg
-
The function to incorporate the AsyncReplyChannel into
the message to be sent.
?timeout : int
-
An optional timeout parameter (in milliseconds) to wait for a reply message.
Defaults to -1 which corresponds to Timeout.Infinite.
Returns: 'Reply
The reply from the agent.
|
Posts a message to an agent and await a reply on the channel, synchronously.
The message is generated by applying
|
||
Full Usage:
this.PostAndTryAsyncReply
Parameters:
AsyncReplyChannel<'Reply> -> 'Msg
-
The function to incorporate the AsyncReplyChannel into
the message to be sent.
?timeout : int
-
An optional timeout parameter (in milliseconds) to wait for a reply message.
Defaults to -1 which corresponds to Timeout.Infinite.
Returns: Async<'Reply option>
An asynchronous computation that will return the reply or None if the timeout expires.
|
Like AsyncPostAndReply, but returns None if no reply within the timeout period.
|
||
Full Usage:
this.Receive
Parameters:
int
-
An optional timeout in milliseconds. Defaults to -1 which corresponds
to Timeout.Infinite.
Returns: Async<'Msg>
An asynchronous computation that returns the received message.
|
Waits for a message. This will consume the first message in arrival order. This method is for use within the body of the agent. This method is for use within the body of the agent. For each agent, at most one concurrent reader may be active, so no more than one concurrent call to Receive, TryReceive, Scan and/or TryScan may be active.
|
||
Full Usage:
this.Scan
Parameters:
'Msg -> Async<'T> option
-
The function to return None if the message is to be skipped
or Some if the message is to be processed and removed from the queue.
?timeout : int
-
An optional timeout in milliseconds. Defaults to -1 which corresponds
to Timeout.Infinite.
Returns: Async<'T>
An asynchronous computation that scanner built off the read message.
|
Scans for a message by looking through messages in arrival order until Returns None if a timeout is given and the timeout is exceeded. This method is for use within the body of the agent. For each agent, at most one concurrent reader may be active, so no more than one concurrent call to Receive, TryReceive, Scan and/or TryScan may be active.
|
||
Full Usage:
this.Start
|
Starts the agent. |
||
Full Usage:
this.StartImmediate
|
Starts the agent immediately on the current operating system thread. |
||
Full Usage:
this.TryPostAndReply
Parameters:
AsyncReplyChannel<'Reply> -> 'Msg
-
The function to incorporate the AsyncReplyChannel into
the message to be sent.
?timeout : int
-
An optional timeout parameter (in milliseconds) to wait for a reply message.
Defaults to -1 which corresponds to Timeout.Infinite.
Returns: 'Reply option
The reply from the agent or None if the timeout expires.
|
Like PostAndReply, but returns None if no reply within the timeout period.
|
||
Full Usage:
this.TryReceive
Parameters:
int
-
An optional timeout in milliseconds. Defaults to -1 which
corresponds to Timeout.Infinite.
Returns: Async<'Msg option>
An asynchronous computation that returns the received message or
None if the timeout is exceeded.
|
Waits for a message. This will consume the first message in arrival order. This method is for use within the body of the agent. Returns None if a timeout is given and the timeout is exceeded. This method is for use within the body of the agent. For each agent, at most one concurrent reader may be active, so no more than one concurrent call to Receive, TryReceive, Scan and/or TryScan may be active.
|
||
Full Usage:
this.TryScan
Parameters:
'Msg -> Async<'T> option
-
The function to return None if the message is to be skipped
or Some if the message is to be processed and removed from the queue.
?timeout : int
-
An optional timeout in milliseconds. Defaults to -1 which corresponds
to Timeout.Infinite.
Returns: Async<'T option>
An asynchronous computation that scanner built off the read message.
|
Scans for a message by looking through messages in arrival order until This method is for use within the body of the agent. For each agent, at most one concurrent reader may be active, so no more than one concurrent call to Receive, TryReceive, Scan and/or TryScan may be active.
|
Static members
Static member |
Description
|
Full Usage:
MailboxProcessor.Start(body, isThrowExceptionAfterDisposed, ?cancellationToken)
Parameters:
MailboxProcessor<'Msg> -> Async<unit>
-
The function to produce an asynchronous computation that will be executed
as the read loop for the MailboxProcessor when Start is called.
isThrowExceptionAfterDisposed : bool
-
A flag denoting that an exception will be thrown
when MailboxProcessor.Post is called
after Control.MailboxProcessor has been disposed.
?cancellationToken : CancellationToken
-
An optional cancellation token for the body .
Defaults to Async.DefaultCancellationToken .
Returns: MailboxProcessor<'Msg>
The created MailboxProcessor.
|
Creates and starts an agent. The
|
Full Usage:
MailboxProcessor.Start(body, ?cancellationToken)
Parameters:
MailboxProcessor<'Msg> -> Async<unit>
-
The function to produce an asynchronous computation that will be executed
as the read loop for the MailboxProcessor when Start is called.
?cancellationToken : CancellationToken
-
An optional cancellation token for the body .
Defaults to Async.DefaultCancellationToken .
Returns: MailboxProcessor<'Msg>
The created MailboxProcessor.
|
Creates and starts an agent. The
|
Full Usage:
MailboxProcessor.StartImmediate(body, isThrowExceptionAfterDisposed, ?cancellationToken)
Parameters:
MailboxProcessor<'Msg> -> Async<unit>
-
The function to produce an asynchronous computation that will be executed
as the read loop for the MailboxProcessor when StartImmediately is called.
isThrowExceptionAfterDisposed : bool
-
A flag denotes will be thrown exception
when MailboxProcessor.Post is called
after Control.MailboxProcessor disposed.
?cancellationToken : CancellationToken
-
An optional cancellation token for the body .
Defaults to Async.DefaultCancellationToken .
Returns: MailboxProcessor<'Msg>
The created MailboxProcessor.
|
Creates and starts an agent immediately on the current operating system thread. The
|
Full Usage:
MailboxProcessor.StartImmediate(body, ?cancellationToken)
Parameters:
MailboxProcessor<'Msg> -> Async<unit>
-
The function to produce an asynchronous computation that will be executed
as the read loop for the MailboxProcessor when StartImmediately is called.
?cancellationToken : CancellationToken
-
An optional cancellation token for the body .
Defaults to Async.DefaultCancellationToken .
Returns: MailboxProcessor<'Msg>
The created MailboxProcessor.
|
Creates and starts an agent immediately on the current operating system thread. The
|