// 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 delegate void CallEventHandler(object sender, EventArgs evtargs); public class Demo { public event CallEventHandler StartCall; public event CallEventHandler EndCall; public void Test() { StartCall(this, EventArgs.Empty); Console.WriteLine("Testing"); EndCall(this, EventArgs.Empty); } } public class Program { public static void Main(string[] args) { Demo o = new Demo(); o.StartCall += (sender, evtargs) => { Console.WriteLine("Started"); }; o.EndCall += (sender, evtargs) => { Console.WriteLine("Ended"); }; o.Test(); } } }