title: Sleep Thread With IF condition in C#
body: <p>In my C# windows form, I want to set notification label with loop and thread before fill the data into data grid view . for that I try to use below method and thread.</p>
  
  <p>My Thread is</p>
  
  <pre><code>public void Run()
      {
          System.Windows.Forms.MessageBox.Show("this is System Thread");
          m = new Dashboard();
          string text = "";
          Int32 a = 0;
          do
          {
  
              Thread.Sleep(1000);
  
              notiCount++;
              /*Notifications ne = new Notifications(m.loadNotification);
              ne.Invoke(text);*/
  
  
              //Thread.Sleep(1000);
          }
          while (notiCount &lt;= 10) ;
      }
  </code></pre>
  
  <p>My method is</p>
  
  <pre><code> private void loadINtransfer(string status)
      {
          Int32 x = 0;
          string text="";
          SystemThreadings s = new SystemThreadings();
          Thread t = new Thread(s.Run);
          t.Start();
  
          Thread.Sleep(100);
          do
          {
              if (s.notiCount == 0)
              {
                  text = "Request Data";
                  Thread.Sleep(1000);
                  this.loadNotification(text);
                  // MessageBox.Show("request");
  
              }
              else if (s.notiCount == 3)
              {
                  text = "Fetching Data";
                  Thread.Sleep(1000);
                  //MessageBox.Show("request");
                  this.loadNotification(text);
              }
              else if (s.notiCount == 6)
              {
                  text = "Loading Data";
                  Thread.Sleep(1000);
                  this.loadNotification(text);
                  //MessageBox.Show("loading");
  
              }
              else if (s.notiCount == 9)
              {
                  text = "Done";
                  Thread.Sleep(1000);
                  this.loadNotification(text);
                  //MessageBox.Show("done");
              }
              //Thread.Sleep(200);
          }
          while (s.notiCount != 10);
  
          //Thread.Sleep(5000);
          MessageBox.Show("attach");
          dt = dl.loadTransfer(status);   
          dgvDashboard.AutoGenerateColumns = false;
          dgvDashboard.DataSource = dt;
      }
  </code></pre>
  
  <p>but it only show <code>Done</code> part. other if parts are passing but not show. And I want to wait some time the all parts before load data to grid view. how can I do this. Please help Me.</p>