2013-04-16 64 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

安全得多做第二。第一种选择会导致死锁的情况有很多种。

相关问题