public static async Task GetDialogs() { dialogs_cancelled = false; await client.GetDialogs(0, 0, 0); var lcs = new List <LC>(client.LCs.Count); foreach (var ilc in client.LCs) { lcs.Add(ilc.Value); } ContactListReceived(lcs); await Task.Factory.StartNew(() => { foreach (var lc in client.LCs) { if (dialogs_cancelled) { break; } var pp = lc.Value.GetSmallProfilePhoto().Result; if (pp != null && ContactUpdated != null) { ContactUpdated(new KeyValuePair <int, BitmapImage>(lc.Value.ID, pp)); } Thread.Sleep(500); } }); if (ContactsReceived != null) { ContactsReceived(); } }