简体   繁体   English

如何在后台代理WP7中获取电话联系人

[英]How to Get Phone Contacts in Background Agent WP7

i am trying to sync the contacts to server after every 24 hours . 我尝试每24小时将联系人同步到服务器一次。 so for that purpose I am using background agent. 为此,我正在使用后台代理。 when I try to call contacts it does not get the contacts of the phone . 当我尝试呼叫联系人时,它无法获取电话的联系人。 my code is here ... 我的代码在这里...

protected override void OnInvoke(ScheduledTask task)
{        
   Contacts cons = new Contacts();

   //Identify the method that runs after the asynchronous search completes.
   cons.SearchCompleted += new EventHandler<ContactsSearchEventArgs>(Contacts_SearchCompleted);

   //Start the asynchronous search.
   cons.SearchAsync(String.Empty, FilterKind.None, "Contacts Test #1");

  #if DEBUG_AGENT
   ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(10));
  #endif    
}

void Contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
{
  var a = e.Results;

  //  e.Results.Count();
  NotifyComplete();
}

can anybody let me know what is the issue or suggest a better way .... 谁能让我知道问题出在哪里或提出更好的方法...。

使用以下代码从SearchAsync函数获取结果:

List<Contact> contacts = new List<Contact>( e.Results );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM