public void whilst(Precondition condition, final Outcome outcome, final Function function, int period) {
        final GuardedControl ctrl = new GuardedControl(condition);
        progress.reset();

        Scheduler.RepeatingCommand repeatingCommand = new Scheduler.RepeatingCommand() {
            @Override
            @SuppressWarnings("unchecked")
            public boolean execute() {
                if (!ctrl.shouldProceed()) {
                    // schedule deferred so that 'return false' executes first!
                    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
                        @Override
                        public void execute() {
                            if (ctrl.isAborted()) {
                                progress.finish();
                                outcome.onFailure(EMPTY_CONTEXT);
                            } else {
                                progress.finish();
                                outcome.onSuccess(EMPTY_CONTEXT);
                            }
                        }
                    });
                    return false;
                } else {
                    function.execute(ctrl);
                    progress.tick();
                    return true;
                }
            }
        };

        if (period > 100) {
            Scheduler.get().scheduleFixedPeriod(repeatingCommand, period);
        } else {
            Scheduler.get().scheduleIncremental(repeatingCommand);
        }
    }
public void whilst ( Precondition condition , final Outcome outcome , final Function function , int period ) { final GuardedControl ctrl = new GuardedControl ( condition ) ; progress . reset ( ) ; Scheduler . RepeatingCommand repeatingCommand = new Scheduler . RepeatingCommand ( ) { @ Override @ SuppressWarnings ( "unchecked" ) public boolean execute ( ) { if ( ! ctrl . shouldProceed ( ) ) { Scheduler . get ( ) . scheduleDeferred ( new Scheduler . ScheduledCommand ( ) { @ Override public void execute ( ) { if ( ctrl . isAborted ( ) ) { progress . finish ( ) ; outcome . onFailure ( EMPTY_CONTEXT ) ; } else { progress . finish ( ) ; outcome . onSuccess ( EMPTY_CONTEXT ) ; } } } ) ; return false ; } else { function . execute ( ctrl ) ; progress . tick ( ) ; return true ; } } } ; if ( period > 100 ) { Scheduler . get ( ) . scheduleFixedPeriod ( repeatingCommand , period ) ; } else { Scheduler . get ( ) . scheduleIncremental ( repeatingCommand ) ; } }
Same as {@link #whilst(Precondition, Outcome, Function)} but waits {@code period} millis between calls to
{@code function}.

@param period any value below 100 is ignored!