Skip to main content

Test Page

using System.Diagnostics.Tracing;

    // 1. Classes that derive from EventSource should be sealed. EventSource does not expect non-trivial hierarchy in the inheritance chain
    [EventSource(Name ="MyEventSource")]
    public sealed class MyEventSource : EventSource
    {
        public static MyEventSource Log = new MyEventSource();

     
        private readonly EventCounter counter;

        public MyEventSource()
        {
            this.counter = new EventCounter("count", this);
        }

        [Event(100)]
        public void CountNumbers(int num)
        {
            this.WriteEvent(100, num);
            this.counter.WriteMetric(num);
        }
    }
}

Comments