예제 #1
0
 private void OnCurrentDomainProcessExit(object sender, EventArgs e)
 {
     try
     {
         lock (this.syncRoot)
         {
             if (this.MainTraceWriter != null)
             {
                 this.MainTraceWriter.Close();
             }
             using (List <IThreadSafeTracer> .Enumerator enumerator = this.Tracers.GetEnumerator())
             {
                 while (enumerator.MoveNext())
                 {
                     ThreadSafeTracer threadSafeTracer = (ThreadSafeTracer)enumerator.Current;
                     threadSafeTracer.Close();
                 }
             }
             this.Tracers.Clear();
         }
     }
     catch (Exception ex)
     {
         Trace.WriteLine("TraceManager OnCurrentDomainProcessExit catches:" + ex.Message);
         throw;
     }
 }
예제 #2
0
        internal IThreadSafeTracer CreateTraceSource(string sourceName)
        {
            IThreadSafeTracer result;

            try
            {
                lock (this.syncRoot)
                {
                    ThreadSafeTracer threadSafeTracer = new ThreadSafeTracer(sourceName, this.currentTracingLevel);
                    if (this.MainTraceWriter != null)
                    {
                        TraceListener traceListener = this.MainTraceWriter as TraceListener;
                        if (traceListener == null)
                        {
                            traceListener = new TraceListenerAdapter(this.MainTraceWriter);
                        }
                        threadSafeTracer.AddTraceListener(traceListener);
                    }
                    this.Tracers.Add(threadSafeTracer);
                    result = threadSafeTracer;
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("Could not create new tracer. Error: " + ex.Message);
                throw new InvalidOperationException("Could not create new tracer.", ex);
            }
            return(result);
        }
예제 #3
0
		internal IThreadSafeTracer CreateTraceSource(string sourceName)
		{
			IThreadSafeTracer result;
			try
			{
				lock (this.syncRoot)
				{
					ThreadSafeTracer threadSafeTracer = new ThreadSafeTracer(sourceName, this.currentTracingLevel);
					if (this.MainTraceWriter != null)
					{
						TraceListener traceListener = this.MainTraceWriter as TraceListener;
						if (traceListener == null)
						{
							traceListener = new TraceListenerAdapter(this.MainTraceWriter);
						}
						threadSafeTracer.AddTraceListener(traceListener);
					}
					this.Tracers.Add(threadSafeTracer);
					result = threadSafeTracer;
				}
			}
			catch (Exception ex)
			{
				Trace.WriteLine("Could not create new tracer. Error: " + ex.Message);
				throw new InvalidOperationException("Could not create new tracer.", ex);
			}
			return result;
		}