void backgroundWorkerMessages_DoWork(object sender, DoWorkEventArgs e) { List <Message> messages = new List <Message>(); Tuple <List <Message>, ApiCallResponse> items; Tuple <List <Channel>, ApiCallResponse> channels = Channels.Subscriptions.getOfCurrentUser(this.accessToken); if (channels.Item2.success) { backgroundWorkerMessages.ReportProgress(20, channels.Item1); } else { return; } DateTime newestKnownDateTime = DateTime.MinValue; if (PrivateMessages.Count > 0) { newestKnownDateTime = PrivateMessages.Max(m => m.CreatedAt); } foreach (Channel channel in channels.Item1) { if (channel.type == "net.app.core.pm") { Messages.messageParameters parameter = new Messages.messageParameters(); parameter.include_annotations = true; items = Messages.getMessagesInChannel(this.accessToken, channel.id, parameters: parameter); if (items.Item2.success) { foreach (Message message in items.Item1) { if (message.created_at > newestKnownDateTime) { messages.Add(message); } } } } } foreach (Message message in messages) { if (!string.IsNullOrEmpty(message.text) && !message.is_deleted && !message.machine_only) { ApnItem item = new ApnItem(message, this); if (item != null) { item.isPrivateMessage = true; item.receivingAccount = this; backgroundWorkerMessages.ReportProgress(50, item); } } } backgroundWorkerMessages.ReportProgress(99, null); }