ARTICLE AD BOX
I have a scenario where I need to return a value to the calling service before doing the actual execution. I have used HostingEnvironment.QueueBackgroundWorkItem() to keep the execution in background as the execution need to perform multiple task like database data fetch etc. but the calling service requires value to be returned within 5 seconds so that it will not consider it a miss.
My code looks like this:
[HttpGet] [AXAuthenticationFilter] [Route("callback", Name = "SearchCallBack")] public IHttpActionResult CallBack() { HostingEnvironment.QueueBackgroundWorkItem(ct => ProcessDetails(myXml, Context, CAPIBaseAddress, NAPIBaseAddress, apiKey, storage, OUrl, APIUserId)); return Ok(); }But I observed that the ProcessDetails() method is not able to complete the execution sometimes and skips some of the tasks which it performs at the end. I have gone through the documentation of HostingEnvironment.QueueBackgroundWorkItem() and found that it may stop execution if the application is in idle state etc.
My question is: how can I achieve this scenario where execution is completed, even of value is returned to the calling service?
