public void channelsCallback(List <Message> messages, bool is_deleted = false)
 {
     if (messages != null)
     {
         foreach (Message message in messages)
         {
             if (message == null)
             {
                 continue;
             }
             if (message.machine_only || string.IsNullOrEmpty(message.text))
             {
                 continue;
             }
             if (message.channel_id != "net.app.core.pm")
             {
                 // PM for now
                 continue;
             }
             if (!message.is_deleted)
             {
                 ApnItem item = new ApnItem(message, this);
                 item.receivingAccount = this;
                 PrivateMessages.Add(item);
             }
             else
             {
                 IEnumerable <ApnItem> existing_items = PrivateMessages.Where(item => item.Id.ToString() == message.id);
                 if (existing_items != null)
                 {
                     if (existing_items.Count() > 0)
                     {
                         List <ApnItem> cache = new List <ApnItem>();
                         foreach (ApnItem item in existing_items)
                         {
                             cache.Add(item);
                         }
                         foreach (ApnItem item in cache)
                         {
                             PrivateMessages.Remove(item);
                         }
                         cache = null;
                     }
                 }
             }
         }
     }
 }
        void backgroundWorkerMessages_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            if (e != null)
            {
                switch (e.ProgressPercentage)
                {
                case 20:
                    // Channel list
                    KnownChannels = e.UserState as List <Channel>;
                    if (KnownChannels != null)
                    {
                        foreach (Channel channel in KnownChannels)
                        {
                            if (KnownChannelIds.Contains(channel.id))
                            {
                                KnownChannelIds.Add(channel.id);
                            }
                        }
                    }
                    break;

                case 50:
                    ApnItem item = e.UserState as ApnItem;
                    PrivateMessages.Add(item);
                    // || true muss raus
                    if (showNotifications)
                    {
                        AppController.Current.sendNotification("App.net " + username + " private messages", item.AuthorName, item.Text, item.Avatar, item);
                    }

                    break;

                case 99:
                    streamMarkerPrivateMessagesUpdateComplete = true;
                    InitialUpdateForMessages = true;
                    break;
                }
            }
        }