BufferBlock<T>.ISourceBlock<T>.ReserveMessage(DataflowMessageHeader, ITargetBlock<T>) 方法
定义
由链接的 ITargetBlock<TInput> 调用,以保留以前由此 DataflowMessageHeader 提供的 ISourceBlock<TOutput>。Called by a linked ITargetBlock<TInput> to reserve a previously offered DataflowMessageHeader by this ISourceBlock<TOutput>.
virtual bool System.Threading.Tasks.Dataflow.ISourceBlock<T>.ReserveMessage(System::Threading::Tasks::Dataflow::DataflowMessageHeader messageHeader, System::Threading::Tasks::Dataflow::ITargetBlock<T> ^ target) = System::Threading::Tasks::Dataflow::ISourceBlock<T>::ReserveMessage;
bool ISourceBlock<T>.ReserveMessage (System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<T> target);
abstract member System.Threading.Tasks.Dataflow.ISourceBlock<T>.ReserveMessage : System.Threading.Tasks.Dataflow.DataflowMessageHeader * System.Threading.Tasks.Dataflow.ITargetBlock<'T> -> bool
override this.System.Threading.Tasks.Dataflow.ISourceBlock<T>.ReserveMessage : System.Threading.Tasks.Dataflow.DataflowMessageHeader * System.Threading.Tasks.Dataflow.ITargetBlock<'T> -> bool
Function ReserveMessage (messageHeader As DataflowMessageHeader, target As ITargetBlock(Of T)) As Boolean Implements ISourceBlock(Of T).ReserveMessage
参数
- messageHeader
- DataflowMessageHeader
要保留的消息的 DataflowMessageHeader。The DataflowMessageHeader of the message being reserved.
- target
- ITargetBlock<T>
保留消息的 ITargetBlock<TInput>。The ITargetBlock<TInput> reserving the message.
返回
如果已成功保留该消息,则为 true;否则,为 false。true if the message was successfully reserved; otherwise, false.
实现
例外
messageHeader 无效。The messageHeader is not valid.
target 为 null。The target is null.
注解
只有 ITargetBlock<TInput> 链接到此实例的实例 ISourceBlock<TOutput> 可以使用 ReserveMessage ,并且它必须仅用于保留 DataflowMessageHeader 此源之前提供给目标的实例。Only ITargetBlock<TInput> instances linked to this ISourceBlock<TOutput> instance may use ReserveMessage, and it must only be used to reserve DataflowMessageHeader instances previously offered by this source to the target.
如果 true 返回,则 ITargetBlock<TInput> 必须随后 ConsumeMessage ReleaseReservation 为此消息调用或。If true is returned, the ITargetBlock<TInput> must subsequently call either ConsumeMessage or ReleaseReservation for this message. 如果不这样做,可能会导致源无法将任何进一步的消息传播到此目标或其他目标。Failure to do so may result in the source being unable to propagate any further messages to this or other targets.
ReserveMessage 当目标持有任何内部锁时,不得调用。ReserveMessage must not be called while the target is holding any internal locks. 这样做将违反锁层次结构,以避免数据流网络中的死锁。Doing so will violate the lock hierarchy necessary to avoid deadlocks in a dataflow network.