TraceData() публичный Метод

public TraceData ( System eventCache, string source, System eventType, int id ) : void
eventCache System
source string
eventType System
id int
Результат void
Пример #1
0
        public void TraceData(TraceEventType eventType, int id, params object[] data)
        {
            Initialize();

            if (_internalSwitch.ShouldTrace(eventType) && _listeners != null)
            {
                TraceEventCache manager = new TraceEventCache();

                if (TraceInternal.UseGlobalLock)
                {
                    // we lock on the same object that Trace does because we're writing to the same Listeners.
                    lock (TraceInternal.critSec)
                    {
                        for (int i = 0; i < _listeners.Count; i++)
                        {
                            TraceListener listener = _listeners[i];
                            listener.TraceData(manager, Name, eventType, id, data);
                            if (Trace.AutoFlush)
                            {
                                listener.Flush();
                            }
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < _listeners.Count; i++)
                    {
                        TraceListener listener = _listeners[i];
                        if (!listener.IsThreadSafe)
                        {
                            lock (listener)
                            {
                                listener.TraceData(manager, Name, eventType, id, data);
                                if (Trace.AutoFlush)
                                {
                                    listener.Flush();
                                }
                            }
                        }
                        else
                        {
                            listener.TraceData(manager, Name, eventType, id, data);
                            if (Trace.AutoFlush)
                            {
                                listener.Flush();
                            }
                        }
                    }
                }
            }
        }
        public void TraceData(TraceEventType eventType, int id, object data)
        {
            // Ensure that config is loaded
            Initialize();

            if (internalSwitch.ShouldTrace(eventType) && listeners != null)
            {
                if (TraceInternal.UseGlobalLock)
                {
                    // we lock on the same object that Trace does because we're writing to the same Listeners.
                    lock (TraceInternal.critSec) {
                        for (int i = 0; i < listeners.Count; i++)
                        {
                            TraceListener listener = listeners[i];
                            listener.TraceData(manager, Name, eventType, id, data);
                            if (Trace.AutoFlush)
                            {
                                listener.Flush();
                            }
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < listeners.Count; i++)
                    {
                        TraceListener listener = listeners[i];
                        if (!listener.IsThreadSafe)
                        {
                            lock (listener) {
                                listener.TraceData(manager, Name, eventType, id, data);
                                if (Trace.AutoFlush)
                                {
                                    listener.Flush();
                                }
                            }
                        }
                        else
                        {
                            listener.TraceData(manager, Name, eventType, id, data);
                            if (Trace.AutoFlush)
                            {
                                listener.Flush();
                            }
                        }
                    }
                }
                manager.Clear();
            }
        }
        public void TraceData(TraceEventType eventType, int id, params object[] data)
        {
            this.Initialize();
            TraceEventCache eventCache = new TraceEventCache();

            if (this.internalSwitch.ShouldTrace(eventType) && (this.listeners != null))
            {
                if (TraceInternal.UseGlobalLock)
                {
                    lock (TraceInternal.critSec)
                    {
                        for (int j = 0; j < this.listeners.Count; j++)
                        {
                            TraceListener listener = this.listeners[j];
                            listener.TraceData(eventCache, this.Name, eventType, id, data);
                            if (Trace.AutoFlush)
                            {
                                listener.Flush();
                            }
                        }
                        return;
                    }
                }
                for (int i = 0; i < this.listeners.Count; i++)
                {
                    TraceListener listener2 = this.listeners[i];
                    if (!listener2.IsThreadSafe)
                    {
                        lock (listener2)
                        {
                            listener2.TraceData(eventCache, this.Name, eventType, id, data);
                            if (Trace.AutoFlush)
                            {
                                listener2.Flush();
                            }
                            continue;
                        }
                    }
                    listener2.TraceData(eventCache, this.Name, eventType, id, data);
                    if (Trace.AutoFlush)
                    {
                        listener2.Flush();
                    }
                }
            }
        }
Пример #4
0
        public void TraceData(TraceEventType eventType, int id, params object[] data)
        {
            if (!this.source_switch.ShouldTrace(eventType))
            {
                return;
            }
            object syncRoot = ((ICollection)this.listeners).SyncRoot;

            lock (syncRoot)
            {
                foreach (object obj in this.listeners)
                {
                    TraceListener traceListener = (TraceListener)obj;
                    traceListener.TraceData(null, this.Name, eventType, id, data);
                }
            }
        }