I practiced the WinRT API, but ran into some problems and you need your help.
I want to try DataContractSerializer and link to this site:
http://winrtstoragehelper.codeplex.com/
The code:
Stream inStream = Task.Run(() => readStream.OpenRead()).Result;
I think it should be (bug?):
Stream inStream = await Task.Run(() => readStream.OpenRead());
But the strangest thing is that if I only use:
Stream inStream = readStream.OpenRead());
and I pass this stream to:
DataContractSerializer.WriteObject
The API is stuck forever.
But if I use:
Stream inStream = await Task.Run(() => readStream.OpenRead());
And pass this stream to WriteObject , then it will work fine.
I have no idea why this symptom occurred if I do not use Task.Run and await for the thread.
Can someone give me advice or suggestion?
But
Stream inStream = readStream.OpenRead () method was not named "async"
I do not know why I need to create a Task for this.
Thanks.
source share