mirror of
https://github.com/rudollee/LearningMVC.git
synced 2025-06-07 16:06:21 +00:00
Async adv
This commit is contained in:
parent
ffff01117a
commit
694fc3bea7
@ -10,17 +10,20 @@ namespace LanguageFeatures.Models
|
|||||||
{
|
{
|
||||||
public class MyAsyncMethods
|
public class MyAsyncMethods
|
||||||
{
|
{
|
||||||
public static Task<long?> GetPageLength()
|
public async static Task<long?> GetPageLength()
|
||||||
{
|
{
|
||||||
HttpClient client = new HttpClient();
|
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.
|
// another task while completing http request.
|
||||||
|
|
||||||
return httpTask.ContinueWith((Task<HttpResponseMessage> antecedent) =>
|
//return httpTask.ContinueWith((Task<HttpResponseMessage> antecedent) =>
|
||||||
{
|
//{
|
||||||
return antecedent.Result.Content.Headers.ContentLength;
|
// return antecedent.Result.Content.Headers.ContentLength;
|
||||||
});
|
//});
|
||||||
|
|
||||||
|
return httpMessage.Content.Headers.ContentLength;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user