Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

VSTHRD003 with AuthenticationStateTask

$
0
0

After migrating from .Net 6 to .Net 8, I see the following warning:

VSTHRD003: Avoid awaiting or returning a Task representing work that was not started within your context as that can lead to deadlocks.

This pertains to AuthenticationStateTask where I do

[CascadingParameter] Task<AuthenticationState> AuthenticationStateTask { get; set; }protected override async Task OnInitializedAsync(){    var authState = await AuthenticationStateTask;    ...}

The issue is that it seems to be the way Microsoft does it, see eg Expose the authentication state as a cascading parameter.

Is there a better way to do it that doesn't raise the warning? Or is this a special case where the warning should be turned off?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>