-
Notifications
You must be signed in to change notification settings - Fork 20
How it Works
Jon Wagner edited this page Mar 13, 2013
·
2 revisions
When you ask EventSourceImplementer to create an EventSource for you, ESP will analyze the class or interface you pass to it.
- Class derived from EventSource: ESP will derive from your class and implement all of the abstract methods.
- Interface: ESP will create a class derived from EventSource and implmement all of the interface methods.
- Class NOT derived from EventSource: ESP will create a new class derived from EventSource that will have the same signature as all of the virtual methods on the class. (This is really only useful for Tracing Proxies, which we will cover later.)
The class is created by emitting a dynamic assembly through IL, so the code is small and fast. All of the methods look like this:
if (IsEnabled(level, keyword))
WriteEvent(eventID, parameters);
So, if you have tracing disabled for your event source, the overhead is simply the amount of code to push the parameters on the stack, plus a call to IsEnabled (which is very fast).