System.Diagnostics.SourceSwitch.ShouldTrace C# (CSharp) Method

ShouldTrace() public method

public ShouldTrace ( System eventType ) : bool
eventType System
return bool
        public bool ShouldTrace(System.Diagnostics.TraceEventType eventType) { throw null; }
    }

Usage Example

Example #1
0
        public void TraceEvent(TraceEventType eventType, int id)
        {
            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.TraceEvent(manager, Name, eventType, id);
                            if (Trace.AutoFlush)
                            {
                                listener.Flush();
                            }
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < _listeners.Count; i++)
                    {
                        TraceListener listener = _listeners[i];
                        if (!listener.IsThreadSafe)
                        {
                            lock (listener)
                            {
                                listener.TraceEvent(manager, Name, eventType, id);
                                if (Trace.AutoFlush)
                                {
                                    listener.Flush();
                                }
                            }
                        }
                        else
                        {
                            listener.TraceEvent(manager, Name, eventType, id);
                            if (Trace.AutoFlush)
                            {
                                listener.Flush();
                            }
                        }
                    }
                }
            }
        }
All Usage Examples Of System.Diagnostics.SourceSwitch::ShouldTrace