Here is some simple sample C# code in Visual Studio 2008:
public partial class Form1 : Form
{
private static System.Timers.Timer TestTimer;
public Form1()
{
InitializeComponent();
TestTimer = new System.Timers.Timer();
TestTimer.Elapsed += DoSomething;
}
private void DoSomething(Object source, EventArgs e)
{
}
}
If I right click on the DoSomething assigned as a handler, and select Go to definition, VS finds the body of DoSomething. So far so good.
If I Right Click on it and Find all references it finds nothing. (!?)
If I do either of these actions for the body of DoSomething itself, it finds only itself, not the assignment as an event handler.
Am I missing something obvious? A setting perhaps? In all other cases when you ask for all references that includes the definition and every other reference. I realize the assignment is thinking in terms of delegates, but this seems inconsistent. It would be very convenient to easily find when something was assigned as a handler.
Your event handler declaration is not quite up to snuff. The ElapsedEventHandler delegate has a different signature. Fix:
IntelliSense now will be able to find all references. Do favor using IntelliSense to get the event assignment correct. After you type
+=, press the Tab key twice to let it automatically generate the code.