2013-04-16 67 views
0

使用System.Net.Http.HttpClient調用其他服務時,我有一個像我必須使用ContinueWith和HttpClient嗎?

var response = client.GetAsync("api/MyController").Result; 
if(response.IsSuccessStatusCode) 
... 

代碼是正確的或者我應該做

client.GetAsync("api/MyController").ContinueWith(task => { var response = task.Result; ...} 

回答

0

安全得多做第二。第一種選擇會導致死鎖的情況有很多種。

相關問題