// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; namespace E { public class Program { private delegate void Demo(object sender, EventArgs args); private static event Demo tst; public static void Main(string[] args) { // let us test if it is actually working for(int i = 0; i < 10; i++) { tst += Hello; } Console.WriteLine("if tst was called here we should see so many hellos: " + tst.GetInvocationList().Length); tst(null, null); // let us try to add a lot for(int i = 0; i < 1000000; i++) { tst += Hello; } Console.WriteLine("if tst was called here we should see so many hellos: " + tst.GetInvocationList().Length); // do not call tst here } public static void Hello(object sender, EventArgs args) { Console.WriteLine("Hello"); } } }