public override void Start(StepRoutineInfo stepRoutine) { /* To achieve the effect we want a delegate that checks whether toCheck equals toWaitFor * and if it does proceed the StepRoutine using ProceedStepRoutine. * Then we want to subscribe that delegate to the eventToCheckOn so it will be called when * the event is raised. */ // Create the checking and proceeding delegate. checker = delegate { if (toCheck is null && toWaitFor is null) // Both are null? Proceed. { StepRoutine.ProceedStepRoutine(stepRoutine); return; } if (toCheck is null || toWaitFor is null) // Only one is null? Not there yet. { return; } if (toCheck.Equals(eventToCheckOn)) { StepRoutine.ProceedStepRoutine(stepRoutine); } }; // Subscribe the checking and proceeding delegate to the event so that it is called when // it is raised. eventToCheckOn.Subscribe(checker); }
public override void Start(StepRoutineInfo stepRoutine) { /* To achieve the effect we want, we should create a delegate that calls ProceedStepRoutine. * We subscribe that delegate to the event. * When the event is raised ProceedStepRoutine will be called, then Cleanup will be called * from there and the StepRoutine will proceed. */ // Create the proceeder delegate. proceeder = delegate { StepRoutine.ProceedStepRoutine(stepRoutine); }; // Subscribe the delegate to the event so it will be called when the event is raised. eventToWaitFor.Subscribe(proceeder); }