0
我使用任務發送Httprequests並捕獲它們的響應。在我的代碼,我想知道的是什麼(HttpWebResponse)t.Result和HttpWebResponse響應之間的真正的改變=(HttpWebResponse)myReq.GetResponse
下面是實際的代碼:Task.Result和請求響應之間的區別
public void pageCheck(WebSite webParam){
//SomeCode omitted
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(uri);
HttpWebResponse response = null;
try{
Task<WebResponse> task = Task<WebResponse>.Factory.FromAsync(
myReq.BeginGetResponse,myReq.EndGetResponse,null);
task.ContinueWith(t =>
{
//some code omitted
var responseCode = (HttpWebResponse) t.Result;
//do some things with response code
response = (HttpWebResponse)myReq.GetResponse();
//other code omitted
});
}
}