Esempio n. 1
0
        /// <summary>
        /// Consumes the message (request by other targets).
        /// </summary>
        /// <param name="messageHeader">The message header.</param>
        /// <param name="target">The target.</param>
        /// <param name="messageConsumed">if set to <c>true</c> [message consumed].</param>
        /// <returns></returns>
        public T ConsumeMessage(
            DataflowMessageHeader messageHeader,
            ITargetBlock <T> target,
            out bool messageConsumed)
        {
            T result = Source.ConsumeMessage(messageHeader, target, out messageConsumed);

            BlockInfo.PoolRequestCounters.Increment(messageConsumed);

            #region BlockInfo.PoolRequest.Add(...)

            var hookTarget = target as ITargetHook <T>;
            if (!(target is LinkHook <T>)) // optimization, in this case the like hook will handle the message
            {
                string targetName = string.Empty;
                if (hookTarget != null)
                {
                    targetName = hookTarget.BlockInfo.Name;
                }

                var msg = new ConsumeTrace(messageHeader.Id, messageConsumed, BlockInfo.Name, targetName, result);
                BlockInfo.PoolRequest.Add(msg);
            }

            #endregion // BlockInfo.PoolRequest.Add(...)

            BlockInfo.Refresh();

            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Consumes the message (hook the link's messaging).
        /// </summary>
        /// <param name="messageHeader">The message header.</param>
        /// <param name="target">The target.</param>
        /// <param name="messageConsumed">if set to <c>true</c> [message consumed].</param>
        /// <returns></returns>
        public T ConsumeMessage(DataflowMessageHeader messageHeader, ITargetBlock <T> target, out bool messageConsumed)
        {
            T result = _source.ConsumeMessage(messageHeader, target, out messageConsumed);

            LinkInfo.PoolRequestCounters.Increment(messageConsumed);

            var msg = new ConsumeTrace(messageHeader.Id, messageConsumed, _source.BlockInfo.Name, _targetName, result);

            LinkInfo.PoolRequest.Add(msg);
            _source.BlockInfo.PoolRequest.Add(msg);
            return(result);
        }