SignalR.DefaultSubscription.PerformWork C# (CSharp) Method

PerformWork() protected method

protected PerformWork ( List &items, string &nextCursor, int &totalCount, object &state ) : void
items List
nextCursor string
totalCount int
state object
return void
        protected override void PerformWork(ref List<ArraySegment<Message>> items, out string nextCursor, ref int totalCount, out object state)
        {
            var cursors = new List<Cursor>();

            lock (_lockObj)
            {
                items = new List<ArraySegment<Message>>(_cursors.Count);
                for (int i = 0; i < _cursors.Count; i++)
                {
                    Cursor cursor = Cursor.Clone(_cursors[i]);
                    cursors.Add(cursor);

                    MessageStoreResult<Message> storeResult = _cursorTopics[i].Store.GetMessages(cursor.Id, MaxMessages);
                    ulong next = storeResult.FirstMessageId + (ulong)storeResult.Messages.Count;

                    cursor.Id = next;

                    if (storeResult.Messages.Count > 0)
                    {
                        items.Add(storeResult.Messages);
                        totalCount += storeResult.Messages.Count;
                    }
                }

                nextCursor = Cursor.MakeCursor(cursors);

                // Return the state as a list of cursors
                state = cursors;
            }
        }