-1

I intend to call async version for fire & forget scenarios e.g. 1. log writing in Azure Table Storage 2. Pushing a message to service bus.

I do not intend to block or await the external api call. However Web API throws following error:

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

Seems the IIS request thread has to remain active. Even though we're not block api call.

Is there any way we could let the external API continue its operation, using Async/Await?

Abhijeet
  • 13,562
  • 26
  • 94
  • 175
  • 3
    You say you do not intend to await the external API call. Why not? – Jason Boyd Aug 09 '17 at 16:49
  • @JasonBoyd External APi call is for logging purposes, so do not much care whether it succeded or not. Think of it like delegating some task to worker role using Service bus Topics. – Abhijeet Aug 10 '17 at 04:41

1 Answers1

1

Is Async Web API good for any practical purpose?

Yes; 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.

Is there any way we could let the external API continue its operation, using Async/Await?

That's not what async/await is for. You're looking for "fire and forget", which is highly dangerous on ASP.NET, but it is possible.

Stephen Cleary
  • 437,863
  • 77
  • 675
  • 810