title: WPF async Loaded with UI elements
body: <p>I need to hide certain controls on Loaded routed event, and when I start an async task. To eliminate writing two methods for same thing I created async Loaded event and call only async Task for this, but I also need to change Content of two UI StatusBarItems, which can't be in my async method for hiding controls.</p>
  
  <p>I've stumbled upon example like this a few times before, and figured that async/await allows you to update UI directly as long as you call await in same method. </p>
  
  <p>I'm allways in doubt when doing that, so I need to clarify myself If <strong>is this a legit thing to do in async/await or is It a very bad practice?</strong></p>
  
  <p>Here is my example of what I mean:</p>
  
  <pre><code> private async void Window_Loaded(object sender, RoutedEventArgs e)
   {
        //Controls on UI thread - I change their content
        StatusBarItem1.Content = "Some Text";
        StatusBarItem2.Content = "Test Text";
  
        await HideControls(); //Asynchronous task
  
   }
  
   private async Task HideControls()
   {
        await Application.Current.Dispatcher.BeginInvoke(new Action(() =&gt;
        {
            //Hide controls in UI Thread
            var All_labels = My_Grid.Children.OfType&lt;Label&gt;();
  
            foreach (var item in All_Labels)
            {
               item.Visibility = Visibility.Hidden;
            }
  
            TextBox1.Visibility = Visibility.Hidden;
  
        }));
  
    }
  </code></pre>
  
  <p>EDIT (button_click event):</p>
  
  <pre><code>  private async void Btn_Check_Click(object sender, RoutedEventArgs e)
    {
              //First hide controls - if user allready cliked this button
              await HideControls();
  
              //running all tasks one at a time - Task.Delay() between them. In order to keep smoooth UI design
              await Task1();
              await Task2();
              await Task3();
              await Task4();
              await Task5();
     }
  </code></pre>
  
  <p>Thanks for answers in advance !</p>