await in your async
MakeAnalysisRequest it will be executed synchronously. If this is the case, all calls will end and your method will be executed after all.
MakeAnalysisRequest has an
await statement, making it asynchronous, you could create a
Task array and wait them all.
First change your method to return a
static async Task MakeAnalysisRequest(string imageFilePath, string fileName)
//Here a list is populated.
// Some await statement
//List<string> Ids = new List<string();
static void SaveFiles()
var tasks = new List<Task>();
foreach (FileInfo file in files)
//The following is async function.
//The following needs to be called only after the MakeAnalysisRequest function has populated "Ids"
if (Ids.Count > 1)
catch (Exception ex)
Console.WriteLine("There was an error! ");