I'm following this tutorial to send emails from my Azure web role using SendGrid.
This is the relevant part from the tutorial:
// Create credentials, specifying your user name and password.
var credentials = new NetworkCredential("username", "password");
// Create an REST transport for sending email.
var transportREST = REST.GetInstance(credentials);
// Send the email.
transportREST.Deliver(myMessage);
It seems to me that the transportREST.Deliver
function is synchronous. Since it's performing IO I'd prefer to use the new .NET 4.5 async, await instead (all my other code is completely asynchronous). Is this possible? Is there an async API for SendGrid or some way to wrap the existing call?
Currently the SendGrid C# library doesn't haven't async methods because we wanted to maintain compatibility with .NET 4.0.
You could easily make this change yourself. In fact, here's a commit that I later reverted after we decided to stick with .NET 4.0.
Update: As of Oct 24 2013 and sendgrid-csharp 1.2.1, there is a DeliverAsync method available
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With