background preloader

Diagnostics

Facebook Twitter

EventSpy. Free source code and programming help. Introduction Recently I was writing an application that used two RichTextBoxes next to each other, and I wanted them to scroll simultaneously, but the Scroll events weren't appearing to fire! After 10 minutes of documentation reading I thought, wouldn't it be better if I had a tool that told me when events fired? That's when I started to research EventSpy. I started off with a bit of reflection, looping through the events of an object and building and linking a System.EventHandler for every event; this worked, but it threw a nasty error if the event wasn't using a System.EventHandler. foreach (EventInfo info in t.GetEvents()) { info.AddEventHandler(new System.EventHandler(this.EventHandler)); }

Tracing Events Raised by Any C# Object. Free source code and pro. Article and Code Update (16-07-2008) I've updated the article and code based on reader comments—thank you very much for reading and voting!

Tracing Events Raised by Any C# Object. Free source code and pro

The original event tracer class would trace only events that followed the .NET Framework design pattern for events—that's most of the events you'll encounter but not all of the ones that C# allows. I've added a second event tracer class that will trace many of the rest of the events you might find. I've also improved the robustness of the class. Exploring Secrets of .NET Diagnostics.