Επεξεργασία

Κοινή χρήση μέσω


BroadcastBlock<T> Class

Definition

Provides a buffer for storing at most one element at time, overwriting each message with the next as it arrives.

generic <typename T>
public ref class BroadcastBlock sealed : System::Threading::Tasks::Dataflow::IPropagatorBlock<T, T>, System::Threading::Tasks::Dataflow::IReceivableSourceBlock<T>, System::Threading::Tasks::Dataflow::ISourceBlock<T>, System::Threading::Tasks::Dataflow::ITargetBlock<T>
public sealed class BroadcastBlock<T> : System.Threading.Tasks.Dataflow.IPropagatorBlock<T,T>, System.Threading.Tasks.Dataflow.IReceivableSourceBlock<T>, System.Threading.Tasks.Dataflow.ISourceBlock<T>, System.Threading.Tasks.Dataflow.ITargetBlock<T>
type BroadcastBlock<'T> = class
    interface IPropagatorBlock<'T, 'T>
    interface ITargetBlock<'T>
    interface IDataflowBlock
    interface ISourceBlock<'T>
    interface IReceivableSourceBlock<'T>
type BroadcastBlock<'T> = class
    interface IDataflowBlock
    interface IPropagatorBlock<'T, 'T>
    interface ISourceBlock<'T>
    interface ITargetBlock<'T>
    interface IReceivableSourceBlock<'T>
Public NotInheritable Class BroadcastBlock(Of T)
Implements IPropagatorBlock(Of T, T), IReceivableSourceBlock(Of T), ISourceBlock(Of T), ITargetBlock(Of T)

Type Parameters

T

Specifies the type of the data buffered by this dataflow block.

Inheritance
BroadcastBlock<T>
Implements

Remarks

Note

The TPL Dataflow Library (the System.Threading.Tasks.Dataflow namespace) is not distributed with .NET. To install the System.Threading.Tasks.Dataflow namespace in Visual Studio, open your project, choose Manage NuGet Packages from the Project menu, and search online for the System.Threading.Tasks.Dataflow package. Alternatively, to install it using the .NET Core CLI, run dotnet add package System.Threading.Tasks.Dataflow.

BroadcastBlock<T> exposes at most one element at a time. However, unlike WriteOnceBlock<T>, that element will be overwritten as new elements are provided to the block. BroadcastBlock<T> ensures that the current element is broadcast to any linked targets before allowing the element to be overwritten.

Constructors

BroadcastBlock<T>(Func<T,T>, DataflowBlockOptions)

Initializes the BroadcastBlock<T> with the specified cloning function and DataflowBlockOptions.

BroadcastBlock<T>(Func<T,T>)

Initializes the BroadcastBlock<T> with the specified cloning function.

Properties

Completion

Gets a Task that represents the asynchronous operation and completion of the dataflow block.

Methods

Complete()

Signals to the IDataflowBlock that it should not accept nor produce any more messages nor consume any more postponed messages.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
LinkTo(ITargetBlock<T>, DataflowLinkOptions)

Links the ISourceBlock<TOutput> to the specified ITargetBlock<TInput>.

MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the formatted name of this IDataflowBlock instance.

TryReceive(Predicate<T>, T)

Attempts to synchronously receive an available output item from the IReceivableSourceBlock<TOutput>.

Explicit Interface Implementations

IDataflowBlock.Fault(Exception)

Causes the IDataflowBlock to complete in a Faulted state.

IReceivableSourceBlock<T>.TryReceiveAll(IList<T>)

Attempts to synchronously receive all available items from the IReceivableSourceBlock<TOutput>.

ISourceBlock<T>.ConsumeMessage(DataflowMessageHeader, ITargetBlock<T>, Boolean)

Called by a linked ITargetBlock<TInput> to accept and consume a DataflowMessageHeader previously offered by this ISourceBlock<TOutput>.

ISourceBlock<T>.ReleaseReservation(DataflowMessageHeader, ITargetBlock<T>)

Called by a linked ITargetBlock<TInput> to release a previously reserved DataflowMessageHeader by this ISourceBlock<TOutput>.

ISourceBlock<T>.ReserveMessage(DataflowMessageHeader, ITargetBlock<T>)

Called by a linked ITargetBlock<TInput> to reserve a previously offered DataflowMessageHeader by this ISourceBlock<TOutput>.

ITargetBlock<T>.OfferMessage(DataflowMessageHeader, T, ISourceBlock<T>, Boolean)

Offers a message to the ITargetBlock<TInput>, giving the target the opportunity to consume or postpone the message.

Extension Methods

AsObservable<TOutput>(ISourceBlock<TOutput>)

Creates a new IObservable<T> abstraction over the ISourceBlock<TOutput>.

AsObserver<TInput>(ITargetBlock<TInput>)

Creates a new IObserver<T> abstraction over the ITargetBlock<TInput>.

LinkTo<TOutput>(ISourceBlock<TOutput>, ITargetBlock<TOutput>, Predicate<TOutput>)

Links the ISourceBlock<TOutput> to the specified ITargetBlock<TInput> using the specified filter.

LinkTo<TOutput>(ISourceBlock<TOutput>, ITargetBlock<TOutput>, DataflowLinkOptions, Predicate<TOutput>)

Links the ISourceBlock<TOutput> to the specified ITargetBlock<TInput> using the specified filter.

LinkTo<TOutput>(ISourceBlock<TOutput>, ITargetBlock<TOutput>)

Links the ISourceBlock<TOutput> to the specified ITargetBlock<TInput>.

OutputAvailableAsync<TOutput>(ISourceBlock<TOutput>, CancellationToken)

Provides a Task<TResult> that asynchronously monitors the source for available output.

OutputAvailableAsync<TOutput>(ISourceBlock<TOutput>)

Provides a Task<TResult> that asynchronously monitors the source for available output.

Post<TInput>(ITargetBlock<TInput>, TInput)

Posts an item to the ITargetBlock<TInput>.

Receive<TOutput>(ISourceBlock<TOutput>, CancellationToken)

Synchronously receives a value from a specified source and provides a token to cancel the operation.

Receive<TOutput>(ISourceBlock<TOutput>, TimeSpan, CancellationToken)

Synchronously receives a value from a specified source, providing a token to cancel the operation and observing an optional time-out interval.

Receive<TOutput>(ISourceBlock<TOutput>, TimeSpan)

Synchronously receives a value from a specified source, observing an optional time-out period.

Receive<TOutput>(ISourceBlock<TOutput>)

Synchronously receives a value from a specified source.

ReceiveAllAsync<TOutput>(IReceivableSourceBlock<TOutput>, CancellationToken)

Creates an IAsyncEnumerable<T> that enables receiving all of the data from the source.

ReceiveAsync<TOutput>(ISourceBlock<TOutput>, CancellationToken)

Asynchronously receives a value from a specified source and provides a token to cancel the operation.

ReceiveAsync<TOutput>(ISourceBlock<TOutput>, TimeSpan, CancellationToken)

Asynchronously receives a value from a specified source, providing a token to cancel the operation and observing an optional time-out interval.

ReceiveAsync<TOutput>(ISourceBlock<TOutput>, TimeSpan)

Asynchronously receives a value from a specified source, observing an optional time-out period.

ReceiveAsync<TOutput>(ISourceBlock<TOutput>)

Asynchronously receives a value from a specified source.

SendAsync<TInput>(ITargetBlock<TInput>, TInput, CancellationToken)

Asynchronously offers a message to the target message block, allowing for postponement.

SendAsync<TInput>(ITargetBlock<TInput>, TInput)

Asynchronously offers a message to the target message block, allowing for postponement.

TryReceive<TOutput>(IReceivableSourceBlock<TOutput>, TOutput)

Attempts to synchronously receive an item from the ISourceBlock<TOutput>.

Applies to