I have an ASP.NET API method when the client call this method I am going to run 4 tasks each task go and call a url collect data and return it back as a List of objects. now each task take different time to complete so what I am looking for is like this.
- javascript AJAX call my API method
- The API method run 4 tasks and wait any completed task and return data
- The ajax call back the API again and see which tasks completed and take the data again and display it on the browser
Now my solution for this is to save the data returned from the tasks in memory database line couchbase then let a timer on the browser call the API to check if there is any new data has been added and then take it till all the tasks completed.
My question is. Is there is any other solutions for this. I do not want to use asp.net signalr
In order to make my idea clear here what I have in my mind
- The client call the API Method
- The API method en queue a list of tasks to hangfire
- Each job will go call another APIs get data process it and log it to memory database I will use couchbase
- When the My API method finish logging the jobs its return a key to the client
- The client can use this key to call another API method which return for him the recent data
This solution is for this problem
- I have an API method which go search for hotels using multiple hotels providers
- Each provider return data which I need later to process this data and return it to the client.
- Since each provider has its own processing time. some provider give me response after 5 sec and some other providers 30sec and some of them even more.
- I do not want the client to wait all the provider to finish instead I want the client to get result as soon as possible to display it on the browser then i can update the UI each time I go and check if there is new provider has finish returning data to me