Example #1
0
        internal void Exit()
        {
            // Stop listening to events
            m_pipResultListener.Cancel();
            m_forwardingEventListener?.Dispose();

            // The execution log target can be null if the worker failed to attach to master
            if (m_executionLogTarget != null)
            {
                m_executionLogTarget.Deactivate();

                // Remove the notify master target to ensure no further events are sent to it.
                // Otherwise, the events that are sent to a disposed target would cause crashes.
                m_scheduler.RemoveExecutionLogTarget(m_executionLogTarget);
                // Dispose the execution log target to ensure all events are processed
                m_executionLogTarget.Dispose();
            }

            if (m_sendThread.IsAlive)
            {
                // Wait for the queues to drain
                m_sendThread.Join();
            }

            m_sendCancellationSource.Cancel();
        }
        internal void Deactivate()
        {
            m_notifyStream.Deactivate();

            // Remove target to ensure no further events are sent
            // Otherwise, the events that are sent to a disposed target would cause crashes.
            m_scheduler?.RemoveExecutionLogTarget(this);
        }