public void TestMethod1() { //check console output MailManager mailManager = new MailManager(); FaxReceiver faxReceiver = new FaxReceiver(mailManager); PcReceiver pcReceiver = new PcReceiver(mailManager); mailManager.ReceiveEmail("Boss", "Me"); mailManager.ReceiveEmail("HR", "CEO"); }
public FaxReceiver(MailManager mm) { //register interest in event mm.NewMail += FaxMsg; }
public PcReceiver(MailManager mm) { mm.NewMail += PcMsg; }
//to unsubscribe from event public void Unregister(MailManager mm) { mm.NewMail -= FaxMsg; }