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 ...
随机推荐
- BottomupSort算法 c++代码实现
#include <iostream> using namespace std; #define N 100 int A[N]; static int n; void Initial() ...
- Android6.0 中appcompat_v7 报错
更新了AndroidSDK以后 各种错误,新建一个项目会附赠一个appcompat_v7,你只要知道这个是一个兼容包就可以了,具体的特性可以看相关介绍,其实也没啥特别的就是为了兼容低版本的呗, 但是呢 ...
- linux shell变量$#,$@,$0,$1,$2的含义解释
变量说明: $$ Shell本身的PID(ProcessID) $! Shell最后运行的后台Process的PID $? 最后运行的命令的结束代码(返回值) $- 使用Set命令设定的Flag一览 ...
- 发博客用的一些HTML
这个世界,在发生什么? 移动光标 <p style="background: #999999; padding: 5px; font-size: 22px;">< ...
- win10下安装python2与python3以及pip共存
一 分别安装python2和python3 注意: 安装时记得勾选 Add Python.exe to Path 二 安装pip Python3最新版本有pip,无需安装 Python2: 下载pip ...
- Ubuntu彻底删除/卸载mysql,php,apache
一.卸载删除 mysql 1 sudo apt-get autoremove --purge mysql-server-5.02 sudo apt-get remove mysql-server3 s ...
- HDU 6034---Balala Power!(搜索+贪心)
题目链接 Problem Description Talented Mr.Tang has n strings consisting of only lower case characters. He ...
- ASP.NET MVC 开发微信支付H5(外置浏览器支付)
H5支付是指商户在微信客户端外的移动端网页展示商品或服务,用户在前述页面确认使用微信支付时,商户发起本服务呼起微信客户端进行支付. 主要用于触屏版的手机浏览器请求微信支付的场景.可以方便的从外部浏览器 ...
- LoadRunner性能测试-LoadRunner工具安装
Loadrunner11安装 1,在网上下载loadrunner11安装包 (百度可以下载安装包) 2,打开安装文件,点击setup.exe进行安装: 3,win10系统可能会出现如下问题: 提示管理 ...
- 测试环境-memcached安装与说明
一,下载memcached和libevent安装包: 1,Memcache用到了libevent这个库用于Socket的处理,所以还需要安装libevent (这两个包百度上都能找到) 二,安装lib ...