title: Insert delay/wait in code c#
body: <pre><code>    public void OpenUpForm(object sender, EventArgs e)
      {
          if (forms.Count == numberoftimes)
          {
              forms.ForEach(f =&gt;
              {
                  f.Close(); 
                  f.Dispose(); 
              });
              forms.Clear(); 
              //Need Delay Here
              return;
          }
          forms.Add(new Form1());
          forms.Last().Show();
      }
  </code></pre>
  
  <p>Hello I have this code, I need to add delay after <code>forms.Clear();</code> But im new to coding i couldnt figure it out.
  I have tryed with <code>Task.Delay</code> and <code>Thread.Sleep</code> but it locks my user interface. Is it possible to add a delay that dosent lock the application? Thank you.</p>