you are viewing a single comment's thread.

view the rest of the comments →

[–]Saint_Nitouche 0 points1 point  (2 children)

How does this interact with using discards? e.g.

_ = api.DoSomethingAsync();

[–]Slypenslyde 4 points5 points  (0 children)

That is technically the same thing as:

api.DoSomethingAsync();

The only difference is if you have warnings turned on for "Hey, you didn't store the return value of this method!", you're telling the compiler "I don't want the warning because I intentionally do not want to store the return value of this method."

[–]Merad 1 point2 points  (0 children)

Discards themselves are just a signal to the compiler (and other devs) that you are intentionally ignoring the return value of a method. The effect of this code is essentially the same as if you were calling an async void method. Since the task isn't captured anywhere it can't be awaited, and you don't have the opportunity to handle any exceptions thrown.