Flush() public method

public Flush ( ) : void
return void
Ejemplo n.º 1
0
        public static void WriteLine(string message, string category)
        {
            object listenersSyncRoot = TraceImpl.ListenersSyncRoot;

            lock (listenersSyncRoot)
            {
                foreach (object obj in TraceImpl.Listeners)
                {
                    TraceListener traceListener = (TraceListener)obj;
                    traceListener.WriteLine(message, category);
                    if (TraceImpl.AutoFlush)
                    {
                        traceListener.Flush();
                    }
                }
            }
        }
        public void TraceTransfer(int id, string message, Guid relatedActivityId)
        {
            this.Initialize();
            TraceEventCache eventCache = new TraceEventCache();

            if (this.internalSwitch.ShouldTrace(TraceEventType.Transfer) && (this.listeners != null))
            {
                if (TraceInternal.UseGlobalLock)
                {
                    lock (TraceInternal.critSec)
                    {
                        for (int j = 0; j < this.listeners.Count; j++)
                        {
                            TraceListener listener = this.listeners[j];
                            listener.TraceTransfer(eventCache, this.Name, id, message, relatedActivityId);
                            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.TraceTransfer(eventCache, this.Name, id, message, relatedActivityId);
                            if (Trace.AutoFlush)
                            {
                                listener2.Flush();
                            }
                            continue;
                        }
                    }
                    listener2.TraceTransfer(eventCache, this.Name, id, message, relatedActivityId);
                    if (Trace.AutoFlush)
                    {
                        listener2.Flush();
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public static void WriteLine(object value)
        {
            object listenersSyncRoot = TraceImpl.ListenersSyncRoot;

            lock (listenersSyncRoot)
            {
                foreach (object obj in TraceImpl.Listeners)
                {
                    TraceListener traceListener = (TraceListener)obj;
                    traceListener.WriteLine(value);
                    if (TraceImpl.AutoFlush)
                    {
                        traceListener.Flush();
                    }
                }
            }
        }
        public void TraceEvent(TraceEventType eventType, int id, string format, params object[] args)
        {
            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.TraceEvent(eventCache, this.Name, eventType, id, format, args);
                            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.TraceEvent(eventCache, this.Name, eventType, id, format, args);
                            if (Trace.AutoFlush)
                            {
                                listener2.Flush();
                            }
                            continue;
                        }
                    }
                    listener2.TraceEvent(eventCache, this.Name, eventType, id, format, args);
                    if (Trace.AutoFlush)
                    {
                        listener2.Flush();
                    }
                }
            }
        }