Пример #1
0
        static void Main(string[] args)
        {
            //TraceToolEventSink.EIFEventSink, TraceToolEventSink, Version=1.0.1622.23936, Culture=neutral, PublicKeyToken=35bb89f90be2164b
            System.Console.WriteLine(typeof(TraceToolEventSink.EIFEventSink).AssemblyQualifiedName);


            // explicit
            TraceMessageEvent e1 = new TraceMessageEvent();

            e1.Message = "Costly Message";
            myEventSource.Raise(e1);

            // slightly less costly, if the EventSource will not be enabled much of the time.
            if (myEventSource.IsEnabledForType(typeof(TraceMessageEvent)))
            {
                TraceMessageEvent e2 = new TraceMessageEvent();
                e2.Message = "Less Costly Message";
                myEventSource.Raise(e2);
            }

            // static one liner (which wraps the above code sequence)
            TraceMessageEvent.Raise(myEventSource, "Static One Liner Message");

            // static one liner which is raised through the EventSource.Application EventSource.
            TraceMessageEvent.Raise("Static One Liner Message through the Application event source");
        }
Пример #2
0
        /// <summary>
        ///  This method shows an example of request tracing using the 'using()' paradigm.
        /// </summary>
        public void TracedMethod_UsingParadigm()
        {
            using (RequestTrace request = new RequestTrace(requestEventSource))
            {
                // TraceRequestStartEvent generated implicitly

                // we raise an example event through the default Application EventSource.
                // the TraceMessageEvent is also raised through the RequestEventSource.
                TraceMessageEvent.Raise("hello from using sample");

                // TraceRequestEndEvent generated implicitly
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            // sample 1 : use static ErrorMessageEvent
            ErrorMessageEvent.Raise("Error Message Event", 1, "CODE"); // msg, severity, error code

            // sample 2 : create a Trace Message Event instance, fill it then raise from the event source
            TraceMessageEvent messageEvent1 = new TraceMessageEvent();

            messageEvent1.Message = "Costly Message";
            myEventSource.Raise(messageEvent1);

            // sample 3 : static one line (which wraps the above code sequence)
            TraceMessageEvent.Raise(myEventSource, "Static One Line Message");

            // sample 4 : static one line which is raised through the EventSource.Application EventSource.
            TraceMessageEvent.Raise("Static One Line Message through the Application event source");
        }
Пример #4
0
        /// <summary>
        ///  This method shows an example of request tracing using the try..finally paradigm.
        /// </summary>
        public void TraceMethod_TryFinallyParadigm()
        {
            RequestTrace request = new RequestTrace(requestEventSource);

            // TraceRequestStartEvent generated implicitly

            try
            {
                // we raise an example event through the default Application EventSource.
                // the TraceMessageEvent is also raised through the RequestEventSource.
                TraceMessageEvent.Raise("hello from try...finally sample");
            }
            finally
            {
                request.Dispose();
                // TraceRequestEndEvent generated implicitly
            }
        }
Пример #5
0
 static void Main()
 {
     // Raise a TraceMessageEvent event through the Application EventSource.
     TraceMessageEvent.Raise("Hello World");
 }