I create a page in my ASP.NET solution that retrieves most of its data from a third-party API service.
The page itself will have to make about 5 individual API calls to populate all of its controls, as each web API request returns multiple datasets.
I would like to deal with every single web request that I make on a new thread, at the same time, so that loading time is reduced.
Each request that I create looks like this: -
WebRequest request = WebRequest.Create(requestUrl); string response = new StreamReader(request.GetResponse().GetResponseStream()).ReadToEnd(); return new JsonSerializer().Deserialize<OccupationSearch>(new JsonTextReader(new StringReader(response)));
First, should I do this? is it safe? and increase productivity through multithreading.
Secondly, what is the best way to do this? There are many different ways to multithreaded systems, but which are best suited for this task?
Derek source share