Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

make Deliver and CheckForErrors methods async

commit 7d436f6cb48b1fe8f12949fea77bb7ea87fe3cc3 1 parent b11fed6
@brandonmwest brandonmwest authored
Showing with 4 additions and 4 deletions.
  1. +4 −4 SendGrid/SendGridMail/Transport/Web.cs
View
8 SendGrid/SendGridMail/Transport/Web.cs
@@ -48,7 +48,7 @@ internal Web(NetworkCredential credentials, bool https = true)
/// 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 @@ public void Deliver(ISendGrid message)
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 @@ private void AttachFiles(ISendGrid message, MultipartFormDataContent content)
}
}
- private void CheckForErrors (HttpResponseMessage response)
+ private async void CheckForErrors (HttpResponseMessage response)
{
//transport error
if (response.StatusCode != HttpStatusCode.OK) {
@@ -115,7 +115,7 @@ private void CheckForErrors (HttpResponseMessage response)
}
//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))
{

1 comment on commit 7d436f6

@brandonmwest

Going to remove this for now. Might be worth adding methods that are async but they should be separate be called e.g. CheckForErrorsAsync

Please sign in to comment.
Something went wrong with that request. Please try again.