Timeline for Not await an asynchronous method because it is like an endless loop - good practice?
Current License: CC BY-SA 4.0
9 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Aug 23, 2024 at 5:30 | comment | added | Doc Brown | @bracco23: if you say so. For me, the async/await solution described in the other answer looks straightforward and quite understandable. I have implemented background workers myself in the past, before async/await was available in C#, and they always required a lot more complicated, less clear code for achieving the same result. | |
| Aug 23, 2024 at 5:26 | history | edited | freakish | CC BY-SA 4.0 | added 4 characters in body |
| Aug 22, 2024 at 21:01 | comment | added | Craig | @bracco23 I'm not sure it exactly fits async / await (at least not at the level of awaiting the infinite task), but I think it fits just fine into the Task pattern. | |
| Aug 22, 2024 at 16:12 | comment | added | bracco23 | @DocBrown just because it's older and a bit clumsier doesn't mean it isn't better for some use cases. this would definitely be one of those, async/await patterns aren't really designed around this kind of infinitely running task, background worker are. | |
| Aug 22, 2024 at 13:40 | comment | added | freakish | @DocBrown that's pretty much what I've meant by "suppress it". I typically do var _ = ...; which IMO has quite clear intent. | |
| Aug 22, 2024 at 13:19 | comment | added | Doc Brown | ... the background worker solution, if I remember correctly, is an approach older than async/await in C#. It would work, but it is pretty clumsy in comparison with the more modern variants. | |
| Aug 22, 2024 at 13:11 | comment | added | Doc Brown | I did not downvote this, but let me add a remark. It is very easy to get rid of the compiler warning. As soon as one writes Task task = StartValueReading(), the warning vanishes, I tried it out. | |
| Aug 22, 2024 at 9:17 | history | edited | freakish | CC BY-SA 4.0 | added 262 characters in body |
| Aug 22, 2024 at 9:11 | history | answered | freakish | CC BY-SA 4.0 |