Ejemplo n.º 1
0
 // Pass the MailManager object to the constructor
 public Pager(MailManager mm)
 {
     // Construct an instance of the ProcessMailMsgEventHandler
     // delegate that refers to our SendMsgToPager callback method.
     // Register our callback with MailManager's ProcessMailMsg event
     mm.NewMail += SendMsgToPager;
 }
Ejemplo n.º 2
0
 // Pass the MailManager object to the constructor
 public Fax(MailManager mm)
 {
     // Construct an instance of the EventHandler<NewMailEventArgs>
     // delegate that refers to our FaxMsg callback method.
     // Register our callback with MailManager's NewMail event
     mm.NewMail += FaxMsg;
 }
Ejemplo n.º 3
0
        public static void Go()
        {
            // Construct a MailManager object
            MailManager mm = new MailManager();

            // Construct a Fax object passing it the MailManager object
            Fax fax = new Fax(mm);

            // Construct a Pager object passing it the MailManager object
            Pager pager = new Pager(mm);

            // Simulate an incoming mail message
            mm.SimulateNewMail("Jeffrey", "Kristin", "I Love You!");

            // Force the Fax object to unregister itself with the MailManager
            fax.Unregister(mm);

            // Simulate an incoming mail message
            mm.SimulateNewMail("Jeffrey", "Mom & Dad", "Happy Birthday.");
        }
Ejemplo n.º 4
0
 static void Main(string[] args)
 {
     MailManager.Go();
     TypeWithLotsOfEventsTest();
 }
Ejemplo n.º 5
0
 public void Unregister(MailManager mm)
 {
     // Unregister ourself with MailManager's ProcessMailMsg event
     mm.NewMail -= SendMsgToPager;
 }
Ejemplo n.º 6
0
 // This method could be executed to have the Fax object unregister itself with the NewMail
 // event so that it no longer receives notifications
 public void Unregister(MailManager mm)
 {
     // Unregister ourself with MailManager's NewMail event
     mm.NewMail -= FaxMsg;
 }