/// <summary>
 /// The callback that is expected to be invoked when a log message is to process.
 /// </summary>
 /// <param name="message"></param>
 /// <returns></returns>
 public bool ProcessSyncCallback(LocalLogMessage message)
 {
     ProcessSyncCallbackWasCalled       = true;
     MessagePassedToProcessSyncCallback = message;
     MessagePassedToProcessSyncCallback.AddRef();
     return(ProcessSyncCallbackReturnValue);
 }
        /// <summary>
        /// Is called on behalf of <see cref="ProcessingPipelineStage.ProcessMessage"/> (for internal use only).
        /// This method must not throw exceptions.
        /// </summary>
        /// <param name="message">Message to process.</param>
        /// <returns>
        /// true to pass the message to the following stages;
        /// false to stop processing the message.
        /// </returns>
        internal override bool OnProcessMessageBase(LocalLogMessage message)
        {
            try
            {
                // synchronous processing
                bool proceed = ProcessSync(message, out bool queueMessageForAsynchronousProcessing);

                // asynchronous processing
                if (queueMessageForAsynchronousProcessing)
                {
                    if (mDiscardMessagesIfQueueFull)
                    {
                        message.AddRef();
                        bool pushed = mAsyncProcessingMessageStack.TryPush(message);
                        if (pushed)
                        {
                            mTriggerAsyncProcessingEvent.Set();
                        }
                        else
                        {
                            message.Release();
                        }
                    }
                    else
                    {
                        message.AddRef();
                        while (!mAsyncProcessingMessageStack.TryPush(message))
                        {
                            Thread.Sleep(10);
                        }
                        mTriggerAsyncProcessingEvent.Set();
                    }
                }

                return(proceed);
            }
            catch (Exception ex)
            {
                // swallow exception to avoid crashing the application, if the exception is not handled properly
                Debug.Fail("The pipeline stage threw an exception processing the message.", ex.ToString());

                // let the following stages process the message
                // (hopefully this is the right decision in this case)
                return(true);
            }
        }
Ejemplo n.º 3
0
 protected override bool ProcessSync(LocalLogMessage message, out bool queueForAsyncProcessing)
 {
     ProcessSyncWasCalled = true;
     MessagePassedToProcessSync?.Release();
     MessagePassedToProcessSync = message;
     MessagePassedToProcessSync.AddRef();
     return(base.ProcessSync(message, out queueForAsyncProcessing));
 }
Ejemplo n.º 4
0
            public bool ProcessSyncCallback(LocalLogMessage message, out bool queueForAsyncProcessing)
            {
                queueForAsyncProcessing = ProcessSyncCallbackQueueForAsyncProcessing;

                ProcessSyncCallbackWasCalled = true;
                MessagePassedToProcessSyncCallback?.Release();
                MessagePassedToProcessSyncCallback = message;
                MessagePassedToProcessSyncCallback.AddRef();

                return(ProcessSyncCallbackReturnValue);
            }