Before you go and close this question answer provided here Parallel HTTP requests using System.Net.Http.HttpCliente does NOT answer my question at all.
I have the following scenario I want to execute the following RestApi calls in parallel
- GetCountries (I want to wait for result to come back)
- GetSomeOtherData (I dont need to wait but I want to preload in memory for use in next page)
- Get SomethingElse (I dont need to wait but I want to preload in memory for use in next page)
My understanding of "WhenAll" is that it will wait for all to complete and that is not what I need to do.
Using "Task.Run" seems not appropriate as its not "CPU bound" stuff.
So in my head it says "Run them on a different thread" but isnt that what Task.Run does.
How do you handle a situation when you want to execute 3 rest api calls (httpClient) in parallel and you want wait for one and not for the others, the other's result by the time the user goes to the next page , they will be in memory as I will cache them for 1 minute.
EDITED
Is there a better way than below , Why did I do this: so that GetSomeOtherData and SomethingElse run at the same time as GetCountries,and they are not waiting/blocking for any to finish. Somehow it feels wrong but dont know how to improve on this.
_ = Task.Run(async () => { await GetSomeOtherData (); })
_ = Task.Run(async () => { await SomethingElse (); })
var countries=await GetCountries();