Yaaf.FSharp.Helper


AutoCancelAgent<'T>

Defined in Yaaf.FSharp.Helper.dll.

Wrapper for the standard F# agent (MailboxProcessor) that supports stopping of the agent's body using the IDisposable interface (the type automatically creates a cancellation token)

Instance members

Instance memberDescription
add_Error(arg1)
Signature: Handler<Exception> -> unit

Occurs when the execution of the agent results in an exception.

CurrentQueueLength
Signature: int

Returns the number of unprocessed messages in the message queue of the agent.

Error
Signature: IEvent<Handler<Exception>,Exception>

Occurs when the execution of the agent results in an exception.

Post(m)
Signature: m:'T -> unit

Posts a message to the message queue of the MailboxProcessor, asynchronously.

PostAndAsyncReply(buildMessage, timeout)
Signature: (buildMessage:(AsyncReplyChannel<'b> -> 'T) * timeout:int option) -> Async<'b>

Posts a message to an agent and await a reply on the channel, asynchronously.

PostAndReply(buildMessage, timeout)
Signature: (buildMessage:(AsyncReplyChannel<'?22153> -> 'T) * timeout:int option) -> '?22153

Posts a message to an agent and await a reply on the channel, synchronously.

PostAndTryAsyncReply(...)
Signature: (buildMessage:(AsyncReplyChannel<'?22156> -> 'T) * timeout:int option) -> Async<'?22156 option>

Like PostAndAsyncReply, but returns None if no reply within the timeout period.

Receive(timeout)
Signature: (timeout:int option) -> Async<'T>

Waits for a message. This will consume the first message in arrival order.

remove_Error(arg1)
Signature: Handler<Exception> -> unit

Occurs when the execution of the agent results in an exception.

Scan(scanner, timeout)
Signature: (scanner:('T -> Async<'?22140> option) * timeout:int option) -> Async<'?22140>

Scans for a message by looking through messages in arrival order until scanner returns a Some value. Other messages remain in the queue.

TryPostAndReply(buildMessage, timeout)
Signature: (buildMessage:(AsyncReplyChannel<'?22143> -> 'T) * timeout:int option) -> '?22143 option

Like PostAndReply, but returns None if no reply within the timeout period.

TryReceive(timeout)
Signature: (timeout:int option) -> Async<'T option>

Waits for a message. This will consume the first message in arrival order.

TryScan(scanner, timeout)
Signature: (scanner:('T -> Async<'?22148> option) * timeout:int option) -> Async<'?22148 option>

Scans for a message by looking through messages in arrival order until scanner returns a Some value. Other messages remain in the queue.

Static members

Static memberDescription
Start(f)
Signature: (f:(MailboxProcessor<'T> -> Async<unit>)) -> AutoCancelAgent<'T>

Start a new disposable agent using the specified body function (the method creates a new cancellation token for the agent)

Fork me on GitHub