【问题标题】:Is Async Web API good for any practical purpose?Async Web API 是否适合任何实际用途?
【发布时间】:2017-08-09 16:33:03
【问题描述】:

我打算调用异步版本来处理火灾和忘记场景,例如1. Azure 表存储中的日志写入 2. 向服务总线推送消息。

我不打算阻止或等待外部 api 调用。但是 Web API 会抛出以下错误:

Web Api + HttpClient: An asynchronous module or handler completed while an asynchronous operation was still pending

似乎 IIS 请求线程必须保持活动状态。即使我们没有阻止 api 调用。

有什么方法可以让外部 API 使用 Async/Await 继续其操作?

【问题讨论】:

  • 您说您不打算等待外部 API 调用。为什么不呢?
  • @JasonBoyd 外部 APi 调用用于记录目的,所以不要太在意它是否成功。可以将其想象为使用服务总线主题将某些任务委托给辅助角色。

标签: c# azure asynchronous async-await


【解决方案1】:

Async Web API 是否适合任何实际用途?

是的; async web APIs allow your web server to make maximum use of its resources. That is, it helps your web server scale further and faster.

有什么方法可以让外部 API 使用 Async/Await 继续其操作?

That's not what async/await is for。您正在寻找“一劳永逸”,即highly dangerous on ASP.NET, but it is possible

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-11-19
    • 1970-01-01
    • 2014-06-19
    • 2011-04-02
    • 2019-05-17
    • 2015-04-22
    • 2021-07-22
    • 1970-01-01
    相关资源
    最近更新 更多