Example #1
0
                public void FixTheSink(IExecutive exec, object userData)
                {
                    IDetachableEventController idec = exec.CurrentEventController;

                    Console.WriteLine("{0} : {1} is starting to fix the sink.", exec.Now, Name);
                    idec.SuspendFor(TimeSpan.FromMinutes(10.0)); // When the suspend call returns, 10 minutes have passed.

                    Console.WriteLine("{0} : {1} discovered that the disposal needed rewiring.", exec.Now, Name);

                    DateTime when = exec.Now + TimeSpan.FromMinutes(5.0);

                    exec.RequestEvent(new Electrician("Edgar").RewireDisposal, when, idec);
                    Console.WriteLine("{0} : {1} called the electrician and is starting to eat lunch.", exec.Now, Name);
                    idec.Suspend(); // When the suspend call returns (from the electrician calling "Resume",)
                                    // the electrician is done, and presumably the sink is fixed.
                    Console.WriteLine("{0} : {1} was told by the electrician that the disposal is fixed.", exec.Now,
                                      Name);
                    Console.WriteLine("{0} : {1} is resuming fixing the sink.", exec.Now, Name);
                    idec.SuspendFor(TimeSpan.FromMinutes(40.0)); // Finishing fixing the sink requires 40 minutes,
                                                                 // and on return from this call, that time has passed.
                    Console.WriteLine("{0} : {1} is done fixing the sink.", exec.Now, Name);
                }