Click here to Skip to main content
15,896,154 members
Articles / Programming Languages / C#

An instrumented synchronous/asynchronous event manager utilizing EventHandler and Reflection

Rate me:
Please Sign up or sign in to vote.
5.00/5 (12 votes)
16 Oct 20026 min read 98.1K   1K   85  
Implements an instrumented event manager which can be used to invoke event sinks both synchronously and asynchronously. The event sink can be declared using either the System.EventHandler delegate or by reflection.
Debug Trace Initialized: 10/2/2002 1:37:31 PM
1:37:31 PM	EventManager.Invoke: event1
1:37:31 PM	EventManager.Invoke: event2
1:37:35 PM	EventManager.Invoke: event3
Debug Trace Terminated: 10/2/2002 1:37:36 PM

Debug Trace Initialized: 10/2/2002 1:40:58 PM
1:40:58 PM	ERROR: Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at EventManager.EventManager.GetMethodInfo(String reflection) in c:\projects.net\csEventManager\EventManager.cs:line 240
1:40:58 PM	EventManager.Invoke: event1
1:40:58 PM	EventManager.Invoke: event2
1:40:58 PM	ERROR: Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at EventManager.ReflectionSyncEvent.Invoke(Object sender, Object[] args) in c:\projects.net\csEventManager\EventManager.cs:line 79
1:40:58 PM	EventManager.Invoke: event3
Debug Trace Terminated: 10/2/2002 1:41:03 PM

Debug Trace Initialized: 10/2/2002 1:44:25 PM
1:44:25 PM	ERROR: EventManager: Exception registering event: csEventManager.exe/csEventMamager.Events/Event2
System.NullReferenceException: Object reference not set to an instance of an object.
   at EventManager.EventManager.GetMethodInfo(String reflection) in c:\projects.net\cseventmanager\eventmanager.cs:line 240
1:44:25 PM	EventManager.Invoke: event1
1:44:25 PM	EventManager.Invoke: event2
1:44:25 PM	ERROR: Event Manager Invoke Exception
System.NullReferenceException: Object reference not set to an instance of an object.
   at EventManager.ReflectionSyncEvent.Invoke(Object sender, Object[] args) in c:\projects.net\cseventmanager\eventmanager.cs:line 79
1:44:25 PM	EventManager.Invoke: event3
Debug Trace Terminated: 10/2/2002 1:44:28 PM

Debug Trace Initialized: 10/2/2002 1:46:32 PM
1:46:32 PM	ERROR: EventManager: Exception registering event: csEventManager.exe/csEventMamager.Events/Event2
System.NullReferenceException: Object reference not set to an instance of an object.
   at EventManager.EventManager.GetMethodInfo(String reflection) in c:\projects.net\cseventmanager\eventmanager.cs:line 252
1:46:32 PM	EventManager.Invoke: event1
1:46:32 PM	ERROR: EventManager: Undefined event: event2
1:46:32 PM	EventManager.Invoke: event3
Debug Trace Terminated: 10/2/2002 1:46:36 PM

Debug Trace Initialized: 10/2/2002 1:48:31 PM
1:48:31 PM	ERROR: EventManager: Exception registering event: csEventManager.exe/csEventMamager.Events/Event2
System.NullReferenceException: Object reference not set to an instance of an object.
   at EventManager.EventManager.GetMethodInfo(String reflection) in c:\projects.net\cseventmanager\eventmanager.cs:line 252
1:48:39 PM	EventManager.Invoke: event1
1:48:39 PM	ERROR: EventManager: Undefined event: event2
1:48:39 PM	EventManager.Invoke: event3
Debug Trace Terminated: 10/2/2002 1:48:42 PM

Debug Trace Initialized: 10/2/2002 1:49:10 PM
1:49:10 PM	EventManager.Invoke: event1
1:49:10 PM	EventManager.Invoke: event2
1:49:13 PM	EventManager.Invoke: event3
Debug Trace Terminated: 10/2/2002 1:49:16 PM

Debug Trace Initialized: 10/7/2002 4:22:45 PM
4:22:45 PM	EventManager.Invoke: event1
4:22:45 PM	EventManager.Invoke: event2
4:22:47 PM	EventManager.Invoke: event3
Debug Trace Terminated: 10/7/2002 4:22:48 PM

Debug Trace Initialized: 10/7/2002 4:23:22 PM
4:23:22 PM	EventManager.Invoke: event1
4:23:22 PM	EventManager.Invoke: event2
4:23:25 PM	EventManager.Invoke: event3
Debug Trace Terminated: 10/7/2002 4:23:29 PM

Debug Trace Initialized: 10/10/2002 9:37:53 AM
9:37:54 AM	EventManager.Invoke: event1
9:37:54 AM	EventManager.Invoke: event2
9:37:55 AM	EventManager.Invoke: event3
Debug Trace Terminated: 10/10/2002 9:38:02 AM

Debug Trace Initialized: 10/10/2002 11:19:17 AM
11:19:18 AM	EventManager.Invoke: event1
11:19:18 AM	EventManager.Invoke: event2
11:19:22 AM	EventManager.Invoke: event3
Debug Trace Terminated: 10/10/2002 11:19:26 AM

Debug Trace Initialized: 10/10/2002 11:22:10 AM
11:22:10 AM	EventManager.Invoke: event1
11:22:10 AM	EventManager.Invoke: event2
11:22:11 AM	EventManager.Invoke: event3
Debug Trace Terminated: 10/10/2002 11:22:16 AM

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Architect Interacx
United States United States
Blog: https://marcclifton.wordpress.com/
Home Page: http://www.marcclifton.com
Research: http://www.higherorderprogramming.com/
GitHub: https://github.com/cliftonm

All my life I have been passionate about architecture / software design, as this is the cornerstone to a maintainable and extensible application. As such, I have enjoyed exploring some crazy ideas and discovering that they are not so crazy after all. I also love writing about my ideas and seeing the community response. As a consultant, I've enjoyed working in a wide range of industries such as aerospace, boatyard management, remote sensing, emergency services / data management, and casino operations. I've done a variety of pro-bono work non-profit organizations related to nature conservancy, drug recovery and women's health.

Comments and Discussions