Could someone give me an example of how to use the ContactPicker.PickSingleContactAsync() functionality correctly in Windows 8 ASync programming, i’ve tried the following code below and I don’t seem to be able to retrieve the results, let alone proceed. the JavaScript example is a bit vague and I don’t understand JavaScript code. I’m new to ASync programming in C# as well
ContactPicker cp = new ContactPicker();
ContactInformation ci;
Task<ContactInformation> task = cp.PickSingleContactAsync() as Task<ContactInformation>;
await task;
How do I proceed to get results into ‘ci’ ? additionally, how do I ensure I get only contacts with phone numbers to pick from?
Try this:
You can’t
as-cast WinRT asynchronous method results toTask<T>, because they’re (probably) notTask<T>. Eitherawaitthem directly (as above) or use theStartAsTaskextension method: