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的更多相关文章

  1. Calling async method synchronously

    https://stackoverflow.com/questions/22628087/calling-async-method-synchronously/22629216#22629216 ht ...

  2. Should I expose synchronous wrappers for asynchronous methods?

    In a previous post Should I expose asynchronous wrappers for synchronous methods?, I discussed " ...

  3. gRPC应用实践

    What is RPC? Remote Procedure Call is a high-level model for client-server communication. Assume the ...

  4. async & await 的前世今生(Updated)

    async 和 await 出现在C# 5.0之后,给并行编程带来了不少的方便,特别是当在MVC中的Action也变成async之后,有点开始什么都是async的味道了.但是这也给我们编程埋下了一些隐 ...

  5. await and async

    Most people have already heard about the new “async” and “await” functionality coming in Visual Stud ...

  6. 【转】async & await 的前世今生

    async 和 await 出现在C# 5.0之后,给并行编程带来了不少的方便,特别是当在MVC中的Action也变成async之后,有点开始什么都是async的味道了.但是这也给我们编程埋下了一些隐 ...

  7. async & await 的前世今生

    async 和 await 出现在C# 5.0之后,给并行编程带来了不少的方便,特别是当在MVC中的Action也变成async之后,有点开始什么都是async的味道了.但是这也给我们编程埋下了一些隐 ...

  8. Async All the Way

    Asynchronous code reminds me of the story of a fellow who mentioned that the world was suspended in ...

  9. @Async in Spring--转

    原文地址:http://www.baeldung.com/spring-async 1. Overview In this article we’ll explore the asynchronous ...

随机推荐

  1. MessageBoxButtons.OKCancel的选择事件

    private void 退出ToolStripMenuItem1_Click(object sender, EventArgs e) { DialogResult resault = Message ...

  2. LoadRunner接口工作总结

    因为工作中需要开发维护类似枢纽性质的平台,所以经常利用LR进行接口测试.接口自动化测试.接口压力测试.用多了LR,有点不愿意使用报文编辑器进行手工接口测试了.  接口脚本操作过程: 首先:打开LR,N ...

  3. Android - FragmentTabHost 与 Fragment 制作页面切换效果

    使用 FragmentTabHost 与 Fragment 制作页面切换效果 API 19 TabHost已经不建议使用了.用 FragmentTabHost 来代替TabHost.实际上 Fragm ...

  4. 【转载】CANoe 入门 Step by step系列(一)基础应用

    来源:http://www.cnblogs.com/dongdonghuihui/archive/2012/09/26/2704611.html CANoe是Vector公司的针对汽车电子行业的总线分 ...

  5. jmeter 单接口测试方案(接口无业务关联)

    前言 前面开了一篇讲了Jenkins+jmeter+ant的使用,但没有说到具体怎么投入到项目使用,主要介绍了接口测试定义,流程和环境部署,所以我今天要说的就是我是怎么将这个方案投入到实际中使用的.这 ...

  6. 基于jmeter,jenkins,ANT接口,性能测试框架

    背景 公司计划推接口和性能测试,搭建这个性能测试框架框架是希望能够让每个人(开发人员.测试人员)都能快速的进行性能,接口测试,而不需要关注性能测试环境搭建过程.因为,往往配置一个性能环境可能需要很长的 ...

  7. Spring源码情操陶冶-AbstractApplicationContext#registerListeners

    承接前文Spring源码情操陶冶-AbstractApplicationContext#onRefresh 约定web.xml配置的contextClass为默认值XmlWebApplicationC ...

  8. 故障公告:docker swarm集群“群龙无首”引发部分站点无法访问

    今天傍晚 17:38-18:18 左右,由于 docker swarm 集群出现 "The swarm does not have a leader" 问题,造成博问.闪存.园子. ...

  9. net 将手机号码中间的数字替换成星号

    Regex.Replace(link.user_tel, "(\\d{3})(\\d{5})(\\d{3})", "$1*****$3")

  10. 连续子序列最大和的O(NlogN)算法

    对于一个数组,例如:int[] a = {4,-3,5,-2,-1,2,6,-2}找出一个连续子序列,对于任意的i和j,使得a[i]+a[i+1]+a[i+2]+.......+a[j]他的和是所有子 ...