异步方法同步调用法
string jsonstr = hc.GetAsync(url).Result.Content.ReadAsStringAsync().Result; 直接访问result
本文介绍了一种将异步方法以同步方式调用的方法。示例代码中使用了HttpGetAsync方法并直接访问了Result属性来获取数据。这种方式虽然简化了调用流程,但需要注意可能带来的线程阻塞风险。
异步方法同步调用法
string jsonstr = hc.GetAsync(url).Result.Content.ReadAsStringAsync().Result; 直接访问result
4612
1285

被折叠的 条评论
为什么被折叠?