0

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");

Result

I haven't exception.

1 Answer 1

1

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.

https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1.result?view=netframework-4.7.2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.