I'm trying to send an SMS asynchronously from an MVC5 controller.
In the controller I call the following method, which is in another class. I don't need any response from the method and don't care if it fails.
public async void SendSMS(string phoneNumber, string message)
{
await Task.Run(() =>
{
TwilioRestClient twilio = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
twilio.SendSmsMessage(TWILIO_PHONE_NUMBER, phoneNumber, message);
}
);
}
This isn't working for me, as it seems to be running synchronously. Any tips on how to improve the code and get it into working order are appreciated.