Deadclock on calling async methond
Issue:
HttpClient.GetAsync(…) never returns when using await/async
Related Posts:
http://stackoverflow.com/questions/9895048/async-call-with-await-in-httpclient-never-returns
http://stackoverflow.com/questions/10343632/httpclient-getasync-never-returns-when-using-await-async/10351400#10351400
Solution:
Quick fix from here. Instead of writing:
Task tsk = AsyncOperation();
tsk.Wait();
Try:
Task.Run(() => AsyncOperation()).Wait();
Or if you need a result:
var result = Task.Run(() => AsyncOperation()).Result;
Deadclock on calling async methond的更多相关文章
- Calling async method synchronously
https://stackoverflow.com/questions/22628087/calling-async-method-synchronously/22629216#22629216 ht ...
- Should I expose synchronous wrappers for asynchronous methods?
In a previous post Should I expose asynchronous wrappers for synchronous methods?, I discussed " ...
- gRPC应用实践
What is RPC? Remote Procedure Call is a high-level model for client-server communication. Assume the ...
- async & await 的前世今生(Updated)
async 和 await 出现在C# 5.0之后,给并行编程带来了不少的方便,特别是当在MVC中的Action也变成async之后,有点开始什么都是async的味道了.但是这也给我们编程埋下了一些隐 ...
- await and async
Most people have already heard about the new “async” and “await” functionality coming in Visual Stud ...
- 【转】async & await 的前世今生
async 和 await 出现在C# 5.0之后,给并行编程带来了不少的方便,特别是当在MVC中的Action也变成async之后,有点开始什么都是async的味道了.但是这也给我们编程埋下了一些隐 ...
- async & await 的前世今生
async 和 await 出现在C# 5.0之后,给并行编程带来了不少的方便,特别是当在MVC中的Action也变成async之后,有点开始什么都是async的味道了.但是这也给我们编程埋下了一些隐 ...
- Async All the Way
Asynchronous code reminds me of the story of a fellow who mentioned that the world was suspended in ...
- @Async in Spring--转
原文地址:http://www.baeldung.com/spring-async 1. Overview In this article we’ll explore the asynchronous ...
随机推荐
- vue2.0设置proxyTable使用axios进行跨域请求
这里请求的是知乎日报的api,由@izzyleung这位大神提供的,这是github地址. 在vue-cli构建的项目中先安装axios npm install axios -S 这里暂不考虑用vue ...
- 自定义七天签到View
github传送车走你 https://github.com/guanhaoran/signin 因为这个View 是我很早之前写的,这些注释也是我今天刚想往github上传的时候 临时加的 有的注 ...
- easyui-dialog里面的东西
<div id="id_open" class="easyui-dialog" title="公司简介" style="wi ...
- JavaBean规范
JavaBean规范 (1)JavaBean 类必须是一个公共类,并将其访问属性设置为 public ,如: public class user{ …}(2)JavaBean 类必须有一个空的构造函 ...
- C++中使用const修饰指针
在本文中呢,主要讲解四个方面,即:常量数据的与否和常量指针的与否中const如何对指针进行修饰: 1.指向非常量数据的常量指针 对于一个指向非常量数据的常量指针,我们应该清楚的知道,在这我们注重的是指 ...
- 【转载】java InputStream读取数据问题
原文链接:http://www.cnblogs.com/MyFavorite/archive/2010/10/19/1855758.html 1. 关于InputStream.read() 在 ...
- cesium 获取点击点的高程
var picklHandler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);picklHandler .setInputAct ...
- 今天提示MyEclipse Trial Expired,如何手动获取MyEclipse 注册码!很牛!
1.建立JAVA Project,随便命名,只要符合规则就行. 2.在刚刚建好的Project右击src,新建一个类,命名为MyEclipseGen,把.java里本来有的代码全部删掉,再把下面的代码 ...
- [BZOJ 4325][NOIP 2015] 斗地主
一道防AK好题 4325: NOIP2015 斗地主 Time Limit: 30 Sec Memory Limit: 1024 MBSubmit: 820 Solved: 560[Submit] ...
- 消息队列中间件 RocketMQ 源码分析 —— Message 存储