在 windows phone 8 中从手机中读取联系人只有以下代码:
Dim WithEvents objContacts As New Microsoft.Phone.UserData.Contacts
Private Sub ReadContacts
objContacts.SearchAsync("", Microsoft.Phone.UserData.FilterKind.None, Nothing)
'Result will be read from the event
End Sub
'Event
Private Sub A_SearchCompleted(sender As Object, e As Microsoft.Phone.UserData.ContactsSearchEventArgs) Handles A.SearchCompleted
Dim B = e.Results.ToList
End Sub
我的问题是:如何将该功能转换为类中的可等待函数?
例子:
Public Class Contacto
Public Async Function GetContacts() As System.Threading.Tasks.Task(Of List(Of Microsoft.Phone.UserData.Contact))
'Do some work: here's my question
End Function
End Class
'So I can call my function
Dim o as new Contacto
dim Contacts = Await o.GetContacts()
非常感谢,感谢您的回复。