Reputation: 194
I have a google table and download it:
Task<byte[]> _res = Http.GetByteArrayAsync(_webPath);
Then I make a Stream:
Stream _stream = new MemoryStream(_res.Result);
And work with this stream. I want to parse table. In console .net core application this method work good, but when i use it in blazor app, it doesn't work.
Task<byte[]> _res = Http.GetByteArrayAsync(_webPath);
Console.WriteLine("3");
_stream = new MemoryStream(_res.Result);
Console.WriteLine("4");
I haven't exception.
Upvotes: 0
Views: 737
Reputation: 26
The problem is that _res.Result
blocks the thread until the task is completed which results in a deadlock as blazor only has one thread.
Accessing the property's get accessor blocks the calling thread until the asynchronous operation is complete; it is equivalent to calling the Wait method.
You need to await the task with await _res
so that the thread isn't block and can complete the task.
Upvotes: 1