title: C# executing function after async function is finished executing
body: <p>I have to execute a batch process. The Ids are generated and stored in a list. I need to execute the function only after all the Ids are generated. The issue is these Ids are generated inside async function. And because I am using a third party API, marking this function async is mandatory. Here is the code:</p>
  
  <pre><code>static void SaveFiles()
  {
      try
      {
              foreach (FileInfo file in files)
              {
                  //The following is async function.
                  MakeAnalysisRequest(file.FullName, file.Name);
              }
  
              //The following needs to be called only after the MakeAnalysisRequest function has populated "Ids"
              if (Ids.Count &gt; 1)
                  CallBatchProcess(Ids);
  
              Console.WriteLine("Processing images...");
          }
      }
      catch (Exception ex)
      {
          Console.WriteLine("There was an error! ");
      }
      Console.ReadLine();
  }
  
  static async void MakeAnalysisRequest(string imageFilePath, string fileName)
  {
      //Here a list is populated.
      //List&lt;string&gt; Ids = new List&lt;string();
      Ids.Add(obj.Id);
  }
  </code></pre>