Skip to content
New issue

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

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

Already on GitHub? # to your account

Task.FromResult should not be awaited for trivial operations. #1074

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dmarkle
Copy link

@dmarkle dmarkle commented Dec 16, 2024

Awaiting Task.FromResult is a meaningless operation when there's no chance of an exception being raised. Also, in an async method with an await elsewhere in the method, there should be no reason to await Task.FromResult().

I suppose there is a chance that in the second case, a NullReferenceException could be thrown on curResultSet and that would happen before any consumers awaited NextResultAsync(), but I don't think that's a case worth covering.

…. This only results in slowness and complexity for nothing.
@dmarkle dmarkle requested a review from a team as a code owner December 16, 2024 18:27
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant