frogb0x wrote: Is there a good primer on Events and the EventHandler() method in general, somewhere? The ones in MSDN are rather difficult to grasp. It took me quite a while to figure out what they are and why I need them. To understand events you need to understand delegates. In fact an event is really just a very limited delegate. A delegate (or function pointer) is basically a function/methods signature. WHat I mean by this is, is that it looks basically like a method but it has the delegate keyword. Think of this as a placeholder for a method. Example:
delegate void FooHandler(string name);
class ABC
{
public FooHandler Foo;
public void InvokeFoo()
{
Foo("Hello from ABC");
}
}
class XYZ
{
static void MyFoo(string name)
{
Console.WriteLine(name);
}
static void Main()
{
ABC abc = new ABC();
abc.Foo = new FooHandler(MyFoo);
abc.InvokeFoo();
}
}
Now step into this with the debugger, step into every function (F11). This will show you exactly how it works. This allows you specify a method in a different place or you can change them dynamically. Once you have grasped this, I suggest you look at the MSDN documentation on events. Hope this helps :) leppie::AllocCPArticle(Generic DFA State Machine for .NET);