I'm making a large number of client get requests and the below code works fine but how do I go about forcing the execution to stop once a HttpResponseMessage of StatusCode.OK is found and then return that single Task.
public List<Task<HttpResponseMessage>> GetUploadURLAsync(List<string> list)
{
List<Task<HttpResponseMessage>> tasks = new List<Task<HttpResponseMessage>>();
using (HttpClient client = new HttpClient())
{
for(int i = 0; i < list.Count; i++)
{
<client get async code generating task list>
}
Task.WaitAll(tasks.ToArray());
}
return tasks;
}