private IUpdateEvent ResumeHandler(ref EventArgs ea, IDictionary <string, object> globals) { IResume ir = (IResume)ea; var label = ir.ResumeWith(); ea = null; if (String.IsNullOrEmpty(label)) // resume current { scheduler.nextEventTime = scheduler.Resume(); } else if (label.StartsWith(Util.LABEL_IDENT, Util.IC)) // resume specified { scheduler.Suspend(); scheduler.Launch(label); } else // resume chat returned by Find { scheduler.Suspend(); UpdateFinder(ref findDelegate, label); runtime.FindAsync(findDelegate, globals); } return(null); }
internal IUpdateEvent HandleCommand(Command cmd, IDictionary <string, object> globals) { if (ChatRuntime.LOG_FILE != null) { WriteToLog(cmd); } cmd.Resolve(globals); if (cmd is ISendable) { if (cmd.GetType() == typeof(Wait)) { if (cmd.delay > Util.INFINITE) // non-infinite WAIT? { // just pause internally, no event needs to be fired ComputeNextEventTime(cmd); return(null); } scheduler.Suspend(); // suspend on infinite WAIT } else if (cmd is Ask) { scheduler.prompt = (Ask)cmd; scheduler.Suspend(); // wait on ChoiceEvent } else { ComputeNextEventTime(cmd); // compute delay for next cmd } return(new UpdateEvent(cmd.Resolve(globals))); // fire event } else if (cmd is Find) { scheduler.Completed(false); runtime.FindAsync((Find)cmd); // finish, then do the Find } return(null); }