JoinBlock<T1,T2>.ISourceBlock<Tuple<T1,T2>>.ReserveMessage(DataflowMessageHeader, ITargetBlock<Tuple<T1,T2>>) 方法
定义
保留将 DataflowMessageHeader 标识的消息的所有权从此 ISourceBlock<TOutput> 传递到 ITargetBlock<TInput> 的权限。Reserves the right to pass the ownership of the message identified by the DataflowMessageHeader from this ISourceBlock<TOutput> to the ITargetBlock<TInput>.
virtual bool System.Threading.Tasks.Dataflow.ISourceBlock<System.Tuple<T1,T2>>.ReserveMessage(System::Threading::Tasks::Dataflow::DataflowMessageHeader messageHeader, System::Threading::Tasks::Dataflow::ITargetBlock<Tuple<T1, T2> ^> ^ target) = System::Threading::Tasks::Dataflow::ISourceBlock<Tuple<T1, T2> ^>::ReserveMessage;
bool ISourceBlock<Tuple<T1,T2>>.ReserveMessage (System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<Tuple<T1,T2>> target);
abstract member System.Threading.Tasks.Dataflow.ISourceBlock<System.Tuple<T1,T2>>.ReserveMessage : System.Threading.Tasks.Dataflow.DataflowMessageHeader * System.Threading.Tasks.Dataflow.ITargetBlock<'T1 * 'T2> -> bool
override this.System.Threading.Tasks.Dataflow.ISourceBlock<System.Tuple<T1,T2>>.ReserveMessage : System.Threading.Tasks.Dataflow.DataflowMessageHeader * System.Threading.Tasks.Dataflow.ITargetBlock<'T1 * 'T2> -> bool
Function ReserveMessage (messageHeader As DataflowMessageHeader, target As ITargetBlock(Of Tuple(Of T1, T2))) As Boolean Implements ISourceBlock(Of Tuple(Of T1, T2)).ReserveMessage
参数
- messageHeader
- DataflowMessageHeader
要保留的消息的 DataflowMessageHeader。The DataflowMessageHeader of the message that is to be reserved.
- target
- ITargetBlock<Tuple<T1,T2>>
要为其保留消息的 ITargetBlock<TInput>。The ITargetBlock<TInput> for which the message is to be reserved.
返回
如果已成功保留该消息,则为 true;否则,为 false。true if the message was successfully reserved; otherwise, false.
实现
例外
messageHeader 无效。The messageHeader is not valid.
target 为 null(在 Visual Basic 中为 Nothing)。The target is null (Nothing in Visual Basic).
注解
ITargetBlock<TInput>要为其保留消息的不需要从该 ISourceBlock<TOutput> 实例链接。The ITargetBlock<TInput> for which the message is to be reserved need not be linked from this ISourceBlock<TOutput> instance. 此外,此 ISourceBlock<TOutput> 实例可能从未直接向提供消息 ITargetBlock<TInput> 。Moreover, this ISourceBlock<TOutput> instance may have never offered the message directly to the ITargetBlock<TInput>.
如果 true 返回,则您随后必须对 ConsumeMessage ReleaseReservation 具有相同和的此消息调用或 DataflowMessageHeader ITargetBlock<TInput> 。If true is returned, you must subsequently call either ConsumeMessage or ReleaseReservation for this message with the same DataflowMessageHeader and ITargetBlock<TInput>. 如果不这样做,源可能无法向任何目标传播任何进一步的消息。If you don't, the source may be unable to propagate any further messages to any target.
ReserveMessage当目标持有任何内部锁时,请不要调用。Don't call ReserveMessage while the target is holding any internal locks. 这样做将违反锁层次结构,以避免数据流网络中的死锁。Doing so will violate the lock hierarchy necessary to avoid deadlocks in a dataflow network.