public Task<AllEventsSlice> ReadAllEventsBackwardAsync(Position position, int maxCount, bool resolveLinkTos, UserCredentials userCredentials = null)
        {
            Ensure.Positive(maxCount, "maxCount");

            var source = new TaskCompletionSource<AllEventsSlice>();
            var operation = new ReadAllEventsBackwardOperation(_settings.Log, source, position, maxCount,
                                                               resolveLinkTos, _settings.RequireMaster, userCredentials);
            EnqueueOperation(operation);
            return source.Task;
        }
        /// <summary>
        /// Reads All Events in the node backwards (e.g. end to beginning)
        /// </summary>
        /// <param name="position">The position to start reading from</param>
        /// <param name="maxCount">The maximum count to read</param>
        /// <param name="resolveLinkTos">Whether to resolve LinkTo events automatically</param>
        /// <returns>A <see cref="AllEventsSlice"/> containing the records read</returns>
        public Task<AllEventsSlice> ReadAllEventsBackwardAsync(Position position, int maxCount, bool resolveLinkTos)
        {
            Ensure.Positive(maxCount, "maxCount");
            EnsureActive();

            var source = new TaskCompletionSource<AllEventsSlice>();
            var operation = new ReadAllEventsBackwardOperation(source, Guid.NewGuid(), position, maxCount, resolveLinkTos);

            EnqueueOperation(operation);
            return source.Task;
        }
 public Task<AllEventsSlice> ReadAllEventsBackwardAsync(Position position, int maxCount, bool resolveLinkTos, UserCredentials userCredentials = null)
 {
     Ensure.Positive(maxCount, "maxCount");
     if (maxCount > Consts.MaxReadSize) throw new ArgumentException(string.Format("Count should be less than {0}. For larger reads you should page.", Consts.MaxReadSize));
     var source = new TaskCompletionSource<AllEventsSlice>();
     var operation = new ReadAllEventsBackwardOperation(_settings.Log, source, position, maxCount,
                                                        resolveLinkTos, _settings.RequireMaster, userCredentials);
     EnqueueOperation(operation);
     return source.Task;
 }