public IReactive <T> GetCurrentAsync() { return(Reactive.From <T>(async resultResolver => { using (ContextualStream <T> childStream = stream.CreateChildWithin(new CSScope(valueScope: InfiniteIntervalScope.Create( RWScope.Read, 0, null)))) using (IAccessContext <enumeratorScope> childEnumContext = context.CreateChildWithin(new enumeratorScope( RWScope.Read, RWScope.Read))) { long curNextIndex = await readNextIndex(childEnumContext); childEnumContext.RequiredScope = new enumeratorScope(RWScope.Read); CSScope readValueScope = new CSScope(valueScope: InfiniteIntervalScope.Create( RWScope.Read, curNextIndex - 1, curNextIndex)); childStream.Context.RequiredScope = readValueScope; node curNode = await readCurrentNode(childEnumContext); childEnumContext.Dispose(); if (curNode == null) { throw new InvalidOperationException( "The enumerator is already disposed."); } await childStream.Context.UntilAvailable( readValueScope); resultResolver.Resolve(curNode.Value); } })); }