1
在我的應用程序使用AddressChooserTask
獲得聯繫方式Contact類搜索異步
AddressChooserTask m_AddressChooserTask = new AddressChooserTask();
m_AddressChooserTask.Completed += new EventHandler<AddressResult>(OnAddressChooserTaskCampleted);
m_AddressChooserTask.Show();
但每次我有一個錯誤在我的事件處理程序的時間
void OnAddressChooserTaskCampleted(object sender, AddressResult e)
{
if (e.TaskResult == TaskResult.OK)
{
m_ContactRec.m_Name = e.DisplayName.ToString();
}
if (m_ContactRec.m_Name != null)
{
Contacts m_contacts = new Contacts();
m_contacts.SearchCompleted += new EventHandler<ContactsSearchEventArgs>(OnContactsSearchCompleted);
m_contacts.SearchAsync(m_ContactRec.m_Name, FilterKind.DisplayName, null);
}
}
調試器在這裏停止m_contacts.SearchAsync
。我有點困惑,這個事件cleary是在UI線程中,你能告訴我我做錯了什麼?
謝謝你的伴侶,現在我感覺很愚蠢 –