Wednesday, October 04, 2006

Delegates and Events simple examples

Some code to help me remeber how to use the two quickly:


public delegate void FSCommandEventHandler(string command, string args);
public delegate void FlashCallEventHandler(string request);
public delegate Stream LoadResourceEventHandler(string path);

public event FSCommandEventHandler MyOnFSCommand;
public event FlashCallEventHandler MyOnFlashCall;
public event LoadResourceEventHandler MyOnLoadResource;

...

this.MyOnFlashCall += new FlashCallEventHandler(FPC_MyOnFlashCall);
void FPC_MyOnFlashCall(string request)
{
XmlDocument requestXml = new XmlDocument();
///...