protected void InnerDistributeMessage(ref LogMessage lm, int srcDistGroupID)
            {
                // all validation and testing of passed parameters is performed by caller
                // message ptr is non-null, message type are enabled in group and distGroupID is known valid

                PerDistGroupIDInfo srcDgInfo = distGroupIDInfoList[srcDistGroupID];
                bool messageHasBeenReallocated = false;

                // traverse groups to which this group is linked and deliver the message to each group's list of log message handlers.
                foreach (PerDistGroupIDInfo dgInfo in srcDgInfo.LinkedDistGroupArray)
                {
                    if (!srcDgInfo.ActiveLoggerConfig.SupportsReferenceCountedRelease && !messageHasBeenReallocated)
                    {
                        ReallocateMessageForNonRefCountedHandler(ref lm);
                        messageHasBeenReallocated = true;
                    }

                    // tell each of the log message handlers in this group to process this message

                    foreach (DistHandlerInfo dhInfo in dgInfo.distHandlerInfoList)
                    {
                        if (dhInfo.Valid && dhInfo.LoggerConfig.IsTypeEnabled(lm.MesgType))
                            dhInfo.LMH.HandleLogMessage(lm);
                    }
                }

                // release the message if we still have a handle to it

                if (lm != null)
                    lm.RemoveReference(ref lm);
            }
            /// <summary>used to support QueuedLogger loggers.  This method consumes the given message.  The caller's handle will be nulled by this method.</summary>
            public void EnqueueMessageForDistribution(ref LogMessage lm)
            {
                MessageQueue capturedMesgQueue = mesgQueue;

                if (capturedMesgQueue == null)
                {
                    StartQueuedMessageDelivery();
                    capturedMesgQueue = mesgQueue;
                }

                if (lm != null)
                {
                    // enqueue the given message and then reset the pointer that was passed to us.
                    //	(this method consumes the given message);

                    if (capturedMesgQueue != null)
                        capturedMesgQueue.EnqueueMesg(lm);

                    lm.RemoveReference(ref lm);		// mesgQueue always adds a reference internally - as such we must explicitly remove the caller's reference before returing
                }
            }
 public override void EmitLogMessage(ref LogMessage mesg)
 {
     mq.InnerEnqueueMesg(mesg);
     mesg.RemoveReference(ref mesg);
 }
            protected void InnerTestAndDistributeMessage(ref LogMessage lm)
            {
                if (lm != null && lm.LoggerSourceInfo != null && lm.Emitted)
                {
                    int lid = lm.LoggerSourceInfo.ID;
                    int dgid = DistGroupID_Invalid;
                    LoggerConfig dgConfig = LoggerConfig.None;

                    if (InnerIsLoggerIDValid(lid))
                    {
                        PerLoggerIDInfo lInfo = perLoggerIDInfoList [lid];
                        dgid = lInfo.distGroupID;
                        lInfo.lastDistributedMesgSeqNum = lm.SeqNum;
                    }

                    bool dgidValid = InnerIsDistGroupIDValid(dgid);

                    if (dgidValid)
                        dgConfig = distGroupIDInfoList [dgid].ActiveLoggerConfig;

                    bool msgEnabled = dgConfig.IsTypeEnabled(lm.MesgType);

                    if (msgEnabled && dgidValid)
                        InnerDistributeMessage(ref lm, dgid);		// this may consume the message (and null our pointer)
                }

                if (lm != null)
                    lm.RemoveReference(ref lm);
            }
                /// <summary>Handles emitting and consuming the given LogMessage.  ref parameter lm will be set to null</summary>
                public override void EmitLogMessage(ref LogMessage lm)
                {
                    if (lm != null)
                    {
                        lm.NoteEmitted();

                        if (!loggerHasBeenShutdown)
                        {
                            if (!lmh.LoggerConfig.SupportsReferenceCountedRelease && lm.BelongsToPool)
                                dist.ReallocateMessageForNonRefCountedHandler(ref lm);

                            lmh.HandleLogMessage(lm);
                        }

                        lm.RemoveReference(ref lm);
                    }
                }