« Compact strongly typed collection pattern, CollectionBase | Main | Syntax for accessing current value of a DataGrid »

reverse engineering event behaviors, StackTrace

The exact sequence and circumstance of raising events is rarely obvious from the documentation of an object. Here are some tricks for quickly adding instrumentation code to your project prior to experimentally exercising the component.

 

An easy way to track the events being raised:

1. In the designer, double click each event of interest in the Properties->Events view.

2. In the code view, enter the line below in each event handler:

Debug.WriteLine((new StackTrace()).GetFrame(0).GetMethod().Name);

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)