title: C# wait for task to complete
body: <p>I have a list of methods to execute and some of them are async methods and they take a while to complete. However I need these tasks to finish before the program moves on to the next task as it is doing at the moment because old data is being shown like this.</p>
  
  <p>Any tips on how to do this? These are my tasks. I need the first three tasks to complete their processing before the last two execute.</p>
  
  <pre><code>public MainPage()
  {
      this.InitializeComponent();
      getTemp();
      data = new initialData();            
  
      SetLiveTile();
      liveTile();           
  }
  </code></pre>
  
  <p>PS: This is for a windows 8 metro app</p>
  
  <p>The code for the getTemp() is the following. My problem is that I need the value from this method before I execute the rest of the methods but before the value is obtained, the program goes on to execute the SetLiveTile and liveTile methods. </p>
  
  <pre><code> public async void getTemp()
   {
       var weatherService = new WeatherService.GlobalWeatherSoapClient();
       var result = await weatherService.GetWeatherAsync("", "Malta");
  
       XmlDocument doc = new XmlDocument();
  
       doc.LoadXml(result);
  
       int pos = doc.InnerText.IndexOf(" F");
       string rem = doc.InnerText.Remove(0, pos + 4);
       string weather = rem.Substring(0, 2);
  
       temp = int.Parse(weather);
  }
  </code></pre>
  
  <p>PS: temp is a global variable</p>