I have some data in my windows 8 application which should be shipped with and is just some static data. In fact: It\'s a simple xml file which should get deserialized.
Thanks for posting code. Please try to change your method Load
as the following:
//your code
var file = await StorageFile.GetFileFromApplicationUriAsync(uri).AsTask().ConfigureAwait(false);
//your code
var stream = await file.OpenStreamForReadAsync().ConfigureAwait(false);
//your code
The main difference here is AsTask().ConfigureAwait(false)
EDIT:
Good to hear that it's working. Explanation is quite simple: when you use task.Result
or task.Wait()
on GUI thread in conjunction with await
keyword you're causing deadlock. This happens because after awaiting
code is resumed on the same context it was invoked (in your case - GUI thread). And because GUI thread currently waiting for task to complete (via Result
or Wait()
) deadlock arises and code after await
keyword will never be invoked. ConfigureAwait(false)
specifies that current context can be ignored and thus allows your code to complete successfully. More details on this here: http://blog.stephencleary.com/2012/07/dont-block-on-async-code.html