public async void LoadMessage(bool initialLoad = false) { if (initialLoad || !string.IsNullOrEmpty(token)) { this.LoadMoreButton.Visibility = System.Windows.Visibility.Hidden; this.loadingBar.Visibility = System.Windows.Visibility.Visible; this.loadingBar.Value = 0; Task <DisplayMessagePagination> task = new Task <DisplayMessagePagination>(() => { return(LoadMessageFromGorilla()); } ); task.Start(); DisplayMessagePagination msgs = new DisplayMessagePagination(); try { msgs = await task; } catch (Exception exception) { //this.Close(); MessageBox.Show(exception.Message + "\r\n\r\n" + exception.StackTrace, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } if (msgs != null) { token = msgs.continuationToken; if (msgs.message != null) { foreach (var msg in msgs.message) { AppendMessage(msg); } } } } this.loadingBar.Visibility = System.Windows.Visibility.Hidden; if (!string.IsNullOrEmpty(token)) { this.LoadMoreButton.Visibility = System.Windows.Visibility.Visible; } }
private DisplayMessagePagination CreateDisplayMsgPag(MessagePagination msgPag) { DisplayMessagePagination dmp = new DisplayMessagePagination(); dmp.continuationToken = msgPag.continuationToken; List <DisplayMessage> msgs = new List <DisplayMessage>(); dmp.message = msgs; foreach (Message msg in msgPag.message) { DisplayMessage dmsg = new DisplayMessage(msg, _attManager, null); dmsg.User = AccountController.GetSimpleUserProfile(msg.User); msgs.Add(dmsg); } return(dmp); }