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

Usage of .Result is problematic #372

Closed
soutchilin opened this issue Apr 28, 2023 · 2 comments · Fixed by #378
Closed

Usage of .Result is problematic #372

soutchilin opened this issue Apr 28, 2023 · 2 comments · Fixed by #378
Labels
enhancement New feature or request

Comments

@soutchilin
Copy link

var result = _connectionSvc.Command_WebExecuteAsync(queryString, body, method, customHeaders, contentType, string.Empty, CallerId, _disableConnectionLocking, MaxRetryCount, RetryPauseTime, cancellationToken: cancellationToken).Result;

Hi,

according to https://learn.microsoft.com/en-us/aspnet/core/fundamentals/best-practices?view=aspnetcore-3.0#avoid-blocking-calls the usage of .Result is not okay and can lead to deadlocks. Please consider to use GetAwaiter().GetResult().

Kind regards,
Alexander

@soutchilin soutchilin changed the title Usage of .Result is not problematic Usage of .Result is problematic Apr 28, 2023
@MattB-msft
Copy link
Member

Thanks for pointing this out,

We have gone back and forth on this and discussed this at somewhat great lengths with the folks in the .net team. The general guidance we are getting back is 'it depends on framework / core / version of core' as to the potential for the deadlocking behavior to occur.

Public Doc's are generally targeted at the leading-edge vs the spectrum.

In light of the pending drop of support for .net core 3.1, we can discuss it again.

@MattB-msft MattB-msft added the enhancement New feature or request label Jun 7, 2023
@MattB-msft
Copy link
Member

in the next drop we are dropping support for .net core 3.x and 5.x, as such we will take this suggestion up and make this change.

@MattB-msft MattB-msft mentioned this issue Jun 8, 2023
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants