Sunday, March 30, 2014

Return a Value from a Task

await will unwrap the task and reads it return. if there is something went wrong the exception will be throw. so your code will look more like this:



void async SomeMethod()
{
try
{
ServiceClient proxy = new ServiceClient();
var results = await proxy.CallAsync(param1, param2);
// Do something with result
}
catch
{
//exception handling
}
}






Microsoft Certified Solutions Developer - Windows Store Apps Using C#


No comments:

Post a Comment