Пример #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public RuntimeTrace()
        {
            // Note that a new RuntimeTrace object is created for each
            // consumer.  That means each caller has its own stream with
            // its own state.
            m_blockingStream = new MemoryQueueStream();
            m_listener       = new TextWriterTraceListener(m_blockingStream);
            Trace.Listeners.Add(m_listener);

            TraceManager.TraceInformation("Creating RuntimeTrace service with listener ID: {0}, stream ID: {1}, numListeners: {2}",
                                          (m_listener != null) ? m_listener.GetHashCode().ToString() : "none",
                                          (m_blockingStream != null) ? m_blockingStream.GetHashCode().ToString() : "none",
                                          Trace.Listeners.Count);
        }
Пример #2
0
        public void Dispose()
        {
            string listenerId = (m_listener != null) ? m_listener.GetHashCode().ToString() : "none";
            string streamId   = (m_blockingStream != null) ? m_blockingStream.GetHashCode().ToString() : "none";
            int    numListenersBeforeRemoval = Trace.Listeners.Count;

            if (m_listener != null)
            {
                Trace.Listeners.Remove(m_listener);
                m_listener = null;
            }

            int numListenersAfterRemoval = Trace.Listeners.Count;

            TraceManager.TraceInformation("Disposing RuntimeTrace service with listener ID: {0}, stream ID: {1}, numListeners (before removal): {2}, numListeners (after removal): {3} ",
                                          listenerId,
                                          streamId,
                                          numListenersBeforeRemoval,
                                          numListenersAfterRemoval);
        }