public override void handleNext(_EventDispatch <T> dispatch) { if (_iterator == null) { throw new Exception("No events pending."); } bool?hasMore = null; try { hasMore = _iterator.MoveNext(); if (hasMore ?? false) { dispatch._sendData(_iterator.Current); } else { _iterator = null; dispatch._sendDone(); } } catch (Exception e) { if (hasMore == null) { // Threw in .moveNext(). // Ensure that we send a done afterwards. _iterator = Enumerable.Empty <T>().GetEnumerator(); // new EmptyIterator<Null>(); dispatch._sendError(e, e.StackTrace); } else { // Threw in .current. dispatch._sendError(e, e.StackTrace); } } }
public override void perform(_EventDispatch <T> dispatch) { dispatch._sendData(value); }