I\'m just starting with c# development, and i always strugled with asyncronous programming,Ii have a doubt about performing a task asyncrounously.
I have my own serv
Regarding what you read in the docs, think about this this way:
public async Task OuterMethod()
{
InnerMethod();
}
You've marked OuterMethod async
, yet you're not doing any awaiting. The docs are simply saying that OuterMethod will run synchronously, and you may as well just mark it with void
instead of async Task
. However, the fact that OuterMethod runs synchronously doesn't change the nature of InnerMethod; it may well be asynchronous, and if you're not awaiting it, it will run fire-and-forget style, most likely on a background thread.
In your specific case, InnerMethod would be the method that sends the email. If you're certain you don't care whether sending the email succeeds or fails, I'd suggest calling SmtpClient.SendAsync without awaiting.