private bool TheLoop() { Task.Factory.StartNew(async() => { int maxMessageId = -1; if (Messages.Any()) { maxMessageId = Messages.Select(x => x.Id).Max(); } var unfilterdMessages = await _chatService.GetChatHistory(); var newMessages = unfilterdMessages.Where(x => x.Id > maxMessageId).ToList(); foreach (var message in newMessages) { Messages.Add(message); } if (newMessages.Any()) { ScrollToTheEnd(true); } var authors = unfilterdMessages .Where(x => x.Author.LastTimeOnline >= DateTime.UtcNow) .GroupBy(x => x.Author.Name) .Select(x => x.Key) .ToList(); OnlineUserCollection.Clear(); foreach (var author in authors) { if (!string.IsNullOrEmpty(author)) { OnlineUserCollection.Add(author); } } }); return(!StopTimer); }
/// <summary> /// Initializes the <see cref="OnLineUserService"/> class. /// </summary> static OnLineUserService() { onlineUserList = new OnlineUserCollection(); }
/// <summary> /// Initializes the <see cref="OnLineUserService"/> class. /// </summary> static OnLineUserService() { onlineUserList = new OnlineUserCollection(); }