summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrandon West <brawest@gmail.com>2013-07-27 15:16:06 -0600
committerBrandon West <brawest@gmail.com>2013-07-29 09:28:31 -0600
commit983c867b29df1ddc66556411071d73f39bd8a675 (patch)
tree557f35bb865a3596df78bd1662675e9151ccb286
parent224bdd20d16ce43b4d732cc2c3397dd1967dc6e4 (diff)
downloadsendgrid-csharp-983c867b29df1ddc66556411071d73f39bd8a675.zip
sendgrid-csharp-983c867b29df1ddc66556411071d73f39bd8a675.tar.gz
sendgrid-csharp-983c867b29df1ddc66556411071d73f39bd8a675.tar.bz2
make Deliver and CheckForErrors methods async
-rw-r--r--SendGrid/SendGridMail/Transport/Web.cs8
1 files changed, 4 insertions, 4 deletions
diff --git a/SendGrid/SendGridMail/Transport/Web.cs b/SendGrid/SendGridMail/Transport/Web.cs
index 2e32f47..5e7c2f5 100644
--- a/SendGrid/SendGridMail/Transport/Web.cs
+++ b/SendGrid/SendGridMail/Transport/Web.cs
@@ -48,7 +48,7 @@ namespace SendGridMail.Transport
/// Delivers a message over SendGrid's Web interface
/// </summary>
/// <param name="message"></param>
- public void Deliver(ISendGrid message)
+ public async void Deliver(ISendGrid message)
{
var client = new HttpClient
{
@@ -58,7 +58,7 @@ namespace SendGridMail.Transport
var content = new MultipartFormDataContent();
AttachFormParams(message, content);
AttachFiles(message, content);
- var response = client.PostAsync(Endpoint + ".xml", content).Result;
+ var response = await client.PostAsync(Endpoint + ".xml", content);
CheckForErrors(response);
}
@@ -107,7 +107,7 @@ namespace SendGridMail.Transport
}
}
- private void CheckForErrors (HttpResponseMessage response)
+ private async void CheckForErrors (HttpResponseMessage response)
{
//transport error
if (response.StatusCode != HttpStatusCode.OK) {
@@ -115,7 +115,7 @@ namespace SendGridMail.Transport
}
//TODO: check for HTTP errors... don't throw exceptions just pass info along?
- var content = response.Content.ReadAsStreamAsync().Result;
+ var content = await response.Content.ReadAsStreamAsync();
using (var reader = XmlReader.Create(content))
{