public GroupsInCommonViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator) : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator) { EventAggregator.Subscribe(this); _currentUser = StateService.CurrentContact; StateService.CurrentContact = null; Status = AppResources.Loading; BeginOnThreadPool(() => { if (_currentUser == null) { return; } MTProtoService.GetCommonChatsAsync(_currentUser.ToInputUser(), new TLInt(0), new TLInt(100), result => BeginOnUIThread(() => { Status = result.Chats.Count > 0 ? string.Empty : AppResources.NoGroupsHere; const int firstSliceCount = 11; var firstSlice = new List <TLChatBase>(); var secondSlice = new List <TLChatBase>(); for (var i = 0; i < result.Chats.Count; i++) { _resultsDict[result.Chats[i].Index] = result.Chats[i]; if (i < firstSliceCount) { firstSlice.Add(result.Chats[i]); } else { secondSlice.Add(result.Chats[i]); } } Items.Clear(); foreach (var chat in firstSlice) { Items.Add(chat); } if (secondSlice.Count > 0) { BeginOnUIThread(() => { foreach (var chat in secondSlice) { Items.Add(chat); } }); } }), error => BeginOnUIThread(() => { Status = AppResources.NoGroupsHere; Telegram.Api.Helpers.Execute.ShowDebugMessage("messages.getCommonChats error=" + error); })); }); }