1
0
mirror of https://github.com/rudollee/LearningMVC.git synced 2025-06-07 16:06:21 +00:00

Async adv

This commit is contained in:
wook 2017-04-03 03:20:22 +09:00
parent ffff01117a
commit 694fc3bea7

View File

@ -10,17 +10,20 @@ namespace LanguageFeatures.Models
{
public class MyAsyncMethods
{
public static Task<long?> GetPageLength()
public async static Task<long?> GetPageLength()
{
HttpClient client = new HttpClient();
var httpTask = client.GetAsync("http://apress.com");
//var httpTask = client.GetAsync("http://apress.com");
var httpMessage = await client.GetAsync("http://apress.com");
// another task while completing http request.
return httpTask.ContinueWith((Task<HttpResponseMessage> antecedent) =>
{
return antecedent.Result.Content.Headers.ContentLength;
});
//return httpTask.ContinueWith((Task<HttpResponseMessage> antecedent) =>
//{
// return antecedent.Result.Content.Headers.ContentLength;
//});
return httpMessage.Content.Headers.ContentLength;
}
}
}