I'm just learning how to use async and await. Say I have the following method that sends an email:
public async void Send()
{
// Create a network credentials object
var credentials = new NetworkCredential(azureUserName, azurePassword);
// Create an Web transport for sending the email
var transportWeb = new Web(credentials);
// Send the email
await transportWeb.DeliverAsync(this._email);
}
This code will exist in an MVC app I'm creating. The user will initiate some action in the browser and a call will get made to a controller action method and this email method will eventually get called within the action method.
My understanding is that as soon as the last line is executed (the line with the await), control immediately returns to the caller, while the DeliverAsync method completes its task. Assuming that is correct, let's also assume the email is taking a long time to send, maybe 30 seconds. Will the controller action method return control back to the browser even though the DeliverAsync method is still attempting to execute the send? Ideally this is what I would to have happen.