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
TaskExtensions: Rename AndForget() to CatchAndLog() #8950
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #8950 +/- ##
==========================================
+ Coverage 89.82% 90.45% +0.62%
==========================================
Files 412 419 +7
Lines 11878 12196 +318
Branches 2364 2381 +17
==========================================
+ Hits 10670 11032 +362
+ Misses 681 629 -52
- Partials 527 535 +8 ☔ View full report in Codecov by Sentry. |
Name is not obvious about its intent to me at least. Something like |
|
|
Or |
Description
The name
Task.AndForget()
implies discarding the task. However,AndForget()
does something very important, it observes the task in the background and catches any exceptions which are then forwarded to the global unhandled exception handler inMudGlobal
. If we can not await a task we should never simply discard it like this:_ = SomeMethodAsync();
. Instead we should doSomeMethodAsync().AndForget();
. To make the significance of not discarding more evident I renamed the methodAndForget
toCatchAndLog
...SomeMethodAsync().CatchAndLog();
... discards the task in a safe manner.Type of Changes
Refactor