Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blazor Webassembly Dispose called before OnInitializedAsync completes #22932

Closed
imtrobin opened this issue Jun 14, 2020 · 1 comment
Closed
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question Status: Resolved

Comments

@imtrobin
Copy link

I have a component that

OnInitializedAsync 
   await  Task A
   await  Task B

Dispose

What I found is the order of calls can be

   Task A
   Dispose
   Task B

This happens because one of my other component will refresh the page. Is that intended?

3.20

@blowdart blowdart added the area-blazor Includes: Blazor, Razor Components label Jun 14, 2020
@javiercn
Copy link
Member

@imtrobin thanks for contacting us.

That is perfectly normal and can happen if the component is removed before the async work completes. You should use a cancellation token source and trigger it on dispose to abort any further work.

@javiercn javiercn added ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question labels Jun 15, 2020
@ghost ghost added the Status: Resolved label Jun 15, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Jul 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question Status: Resolved
Projects
None yet
Development

No branches or pull requests

3 participants