🔷.NET Task FromResult vs CompletedTask
CompletedTask returns a task whose Status is RanToCompletion, you can use it to skip taking system resources to do a job
FromResult returns a Task with a specified result, you can use this to avoid wasting resources to return a value
🔷.NET Task FromResult vs CompletedTask
CompletedTask returns a task whose Status is RanToCompletion, you can use it to skip taking system resources to do a job
FromResult returns a Task with a specified result, you can use this to avoid wasting resources to return a value
This is what I do too, when it's very obvious:
entity.Where(e => e...)
reports.First(r => r...)
If it's not obvious, I prefer to expand it:
results.Where(completedTask => ...)
Generally I shoot for whatever will help the next dev read my code with the least surprise.
Most of us juggle multiple task at the same time with intent that they will all stay in the air. Should one drop we say failure. If one drops just start again God never created failures just those who complete what they start. #completedtask