0

WP8, VS 2013 Live SDK (nuget) v5.5

private async void DownLoadImageFromSkyDrive(string imgUrl, Int32 number)
{
    LiveConnectClient client = new LiveConnectClient(_currentSession);
    var image = await client.DownloadAsync(imgUrl + "/content");
    BitmapImage bitmap = new BitmapImage();
    bitmap.SetSource(image.Stream);
}

After the execution of

var image = await client.DownloadAsync(imgUrl + "/content");

The callstack is in the parent function. There's no exception, but

BitmapImage bitmap = new BitmapImage();

is not executed. The code has worked....

i3arnon
  • 113,022
  • 33
  • 324
  • 344
KevinM
  • 39
  • 4
  • 2
    MSDN has guidance for `async` methods called the [Task-based Asynchronous Pattern (TAP)](http://msdn.microsoft.com/en-us/library/hh873175.aspx). To summarize, you should make your method `async Task` instead of `async void`, name it `DownloadImageFromSkyDriveAsync`, and `await` the returned task from the calling method ("parent function"). – Stephen Cleary Dec 31 '13 at 15:58

1 Answers1

1

Or not yet executed... You function is an async method with no return value. It doesn't block the caller. Also I believe async void won't pass the exception to the caller. Put the try catch block in DownLoadImageFromSkyDrive to see what's going on.

Andras Csehi
  • 4,305
  • 1
  • 28
  • 36