Reputation: 70
I have an ASMX method that's being called from a third party. This method makes several httprequests to various sources, aggregates the data, then pushes said data to a third-party API. Because of varying volumes of data and latency, the request calling the ASMX is intermittently timing out. I'd like to think that after the ASMX is called, it's possible to start the rest of the process asynchronously and just return a response to the original caller. I've been reading through Async/Await docs, but haven't found what I'm looking for, which means I'm missing something, or I'm trying to do it wrong.
1) Is Async the correct solution for what I'm trying to do?
2) If not, can someone help point me in the correct direction?
Forgive the high level and lack of code here - I know what I'm trying to do, but obviously not how, and .NET is not my forte. :) Cheers-
Upvotes: 0
Views: 177
Reputation: 456322
1) Is Async the correct solution for what I'm trying to do?
No. As I describe on my blog, async does not change the HTTP protocol.
2) If not, can someone help point me in the correct direction?
First off, running tasks on ASP.NET without a request context is dangerous. That said, I do cover a few options for fire-and-forget on ASP.NET on my blog. The easiest solutions are probably HangFire or HostingEnvironment.QueueBackgroundWorkItem
.
Upvotes: 0
Reputation: 5128
What you can do is inside your web service call make asynchronous calls to each of the 3rd party web services and then await them all so they run concurrently. However if you need to wait for all the responses and process the data etc before being able to return the result to the client then if waiting for all the results from 3rd party service calls and doing your own processing takes too long and it times out then there's not really much that you can do unless you can just return a simple response right away after calling the 3rd party services asynchronously that just indicates that the request was submitted but not necessarily completed successfully yet.
Upvotes: 1