_Timer(ZoneUnaryCallback callback, long wakeupTime, int milliSeconds, bool repeating) { _callback = callback; _wakeupTime = wakeupTime; _milliSeconds = milliSeconds; _repeating = repeating; }
public ZoneUnaryCallback registerUnaryCallback(Zone zone, ZoneUnaryCallback f) { var implementation = _delegationTarget._registerUnaryCallback; _Zone implZone = implementation.zone; RegisterUnaryCallbackHandler handler = implementation.function; return(handler(implZone, async_._parentDelegate(implZone), zone, f)); }
public Timer createPeriodicTimer(Zone zone, TimeSpan period, ZoneUnaryCallback f) { var implementation = _delegationTarget._createPeriodicTimer; _Zone implZone = implementation.zone; CreatePeriodicTimerHandler handler = implementation.function; return(handler(implZone, async_._parentDelegate(implZone), zone, period, f)); }
public override object runUnary(ZoneUnaryCallback f, object arg) { if (ReferenceEquals(_current, async_._rootZone)) { return(f(arg)); } return(async_._rootRunUnary(null, null, this, f, arg)); }
public override object runUnary(ZoneUnaryCallback f, object arg) { var implementation = _runUnary; ZoneDelegate parentDelegate = async_._parentDelegate(implementation.zone); RunUnaryHandler handler = implementation.function; return(handler(implementation.zone, parentDelegate, this, f, arg)); }
public override ZoneUnaryCallback registerUnaryCallback(ZoneUnaryCallback callback) { var implementation = _registerUnaryCallback; ZoneDelegate parentDelegate = async_._parentDelegate(implementation.zone); RegisterUnaryCallbackHandler handler = implementation.function; return(handler(implementation.zone, parentDelegate, this, callback)); }
public object runUnary(Zone zone, ZoneUnaryCallback f, object arg) { var implementation = _delegationTarget._runUnary; _Zone implZone = implementation.zone; RunUnaryHandler handler = implementation.function; return(handler(implZone, async_._parentDelegate(implZone), zone, f, arg)); }
public override Timer createPeriodicTimer(TimeSpan duration, ZoneUnaryCallback f) { var implementation = _createPeriodicTimer; ZoneDelegate parentDelegate = async_._parentDelegate(implementation.zone); CreatePeriodicTimerHandler handler = implementation.function; return(handler(implementation.zone, parentDelegate, this, duration, f)); }
public override void onData(Action <T> handleData) { _handleData = handleData == null ? null : _zone.registerUnaryCallback(data => { handleData((T)data); return(null); }); }
public override object runUnaryGuarded(ZoneUnaryCallback f, object arg) { try { return(runUnary(f, arg)); } catch (Exception e) { handleUncaughtError(e); return(null); } }
public static Timer periodic(TimeSpan duration, ZoneUnaryCallback callback) { if (Zone.current == Zone.root) { return(Zone.current.createPeriodicTimer(duration, callback)); } var boundCallback = Zone.current.bindUnaryCallbackGuarded(callback); return(Zone.current.createPeriodicTimer(duration, boundCallback)); }
public override object runUnaryGuarded(ZoneUnaryCallback f, object arg) { try { if (ReferenceEquals(async_._rootZone, _current)) { return(f(arg)); } return(async_._rootRunUnary(null, null, this, f, arg)); } catch (Exception e) { handleUncaughtError(e); return(null); } }
internal static _Timer _createTimer(ZoneUnaryCallback callback, int milliSeconds, bool repeating) { if (milliSeconds < 0) { milliSeconds = 0; } long now = UIMonoState_timerMillisecondClock(); long wakeupTime = (milliSeconds == 0) ? now : (now + 1 + milliSeconds); _Timer timer = new _Timer(callback, wakeupTime, milliSeconds, repeating); timer._enqueue(); return(timer); }
public static Future doWhile(Func <FutureOr> action) { _Future doneSignal = new _Future(); ZoneUnaryCallback nextIteration = null; // Bind this callback explicitly so that each iteration isn't bound in the // context of all the previous iterations' callbacks. // This avoids, e.g., deeply nested stack traces from the stack trace // package. nextIteration = Zone.current.bindUnaryCallbackGuarded((object keepGoingObj) => { bool keepGoing = (bool)keepGoingObj; while (keepGoing) { FutureOr result; try { result = action(); } catch (Exception error) { // Cannot use _completeWithErrorCallback because it completes // the future synchronously. async_._asyncCompleteWithErrorCallback(doneSignal, error); return(null); } if (result.isFuture) { result.f.then((value) => { nextIteration((bool)value); return(FutureOr.nil); }, onError: error => { doneSignal._completeError(error); return(FutureOr.nil); }); return(null); } keepGoing = (bool)result.v; } doneSignal._complete(); return(null); }); nextIteration(true); return(doneSignal); }
public override void cancel() { _callback = null; }
public abstract object runUnaryGuarded(ZoneUnaryCallback action, object argument);
public override ZoneUnaryCallback bindUnaryCallbackGuarded(ZoneUnaryCallback f) { var registered = registerUnaryCallback(f); return((arg) => runUnaryGuarded(registered, arg)); }
internal static Timer _createPeriodicTimer( TimeSpan duration, ZoneUnaryCallback callback) { return(_Timer._createTimer(callback, (int)duration.TotalMilliseconds, true)); }
public override ZoneUnaryCallback registerUnaryCallback(ZoneUnaryCallback f) => f;
public override ZoneUnaryCallback bindUnaryCallbackGuarded(ZoneUnaryCallback f) { return((arg) => runUnaryGuarded(f, arg)); }
public override Timer createPeriodicTimer(TimeSpan duration, ZoneUnaryCallback f) { return(Timer._createPeriodicTimer(duration, f)); }
public abstract ZoneUnaryCallback registerUnaryCallback(ZoneUnaryCallback callback);
public abstract Timer createPeriodicTimer(TimeSpan period, ZoneUnaryCallback callback);
public abstract ZoneUnaryCallback bindUnaryCallbackGuarded(ZoneUnaryCallback callback);
public abstract ZoneUnaryCallback bindUnaryCallback(ZoneUnaryCallback callback);