AspNetCoreDiagnosticScenarios | broken patterns in ASP.NET Core applications
kandi X-RAY | AspNetCoreDiagnosticScenarios Summary
kandi X-RAY | AspNetCoreDiagnosticScenarios Summary
# ASP.NET Core Diagnostic Scenarios. The goal of this repository is to show problematic application patterns for ASP.NET Core applications and a walk through on how to solve those issues. It shall serve as a collection of knowledge from real life application issues our customers have encountered.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of AspNetCoreDiagnosticScenarios
AspNetCoreDiagnosticScenarios Key Features
AspNetCoreDiagnosticScenarios Examples and Code Snippets
Community Discussions
Trending Discussions on AspNetCoreDiagnosticScenarios
QUESTION
I am reviewing some code and trying to come up with a technical reason why you should or should not use Task.WhenAll(Tasks[])
for essentially making Http calls in parallel. The Http calls call a different microservice and I guess one of the calls may or may not take some time to execute... (I guess I am not really interested in that). I'm using BenchmarkDotNet to give me an idea of there is any more memory consumed, or if execution time is wildly different. Here is an over-simplified example of the Benchmarks:
ANSWER
Answered 2021-May-12 at 15:51My question really is, is there a technical reason why you should or not use Task.WhenAll()?
The behavior is just slightly different in the case of exceptions when both calls fail. If they're await
ed one at a time, the second failure will never be observed; the exception from the first failure is propagated immediately. If using Task.WhenAll
, both failures are observed; one exception is propagated after both tasks fail.
Is it just a preference?
It's mostly just preference. I tend to prefer WhenAll
because the code is more explicit, but I don't have a problem with await
ing one at a time.
QUESTION
ANSWER
Answered 2020-Jan-03 at 21:49As @Hans Passant pointed out in the comments, there is a BlockingCollection which solves the problem.
It has a limit of items inside and when the limit is reached, it blocks the producer until the number of items decreases.
QUESTION
I'm looking at the "good" example in this scenario, specifically assigning the result of an async method to a variable. (In this case it's a discard variable but it works the same if I just do var x =
).
ANSWER
Answered 2018-Dec-17 at 10:52With the _
keyword its assigning the output of DoAsyncPing()
to _
as a Task
. In that case there is no execution yet its just a task.
Without the _
= then the function is called and the compiler is warning you that the call is not awaited. So the first method is assignment and the second is execution
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install AspNetCoreDiagnosticScenarios
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page