title: Calling a Stored Procedure every n seconds
body: <p>I don't have much experience with multi threading so I am wondering how to refresh my Data Grid View every, for example, two seconds.</p>
  
  <p>Basically, when the user is on a certain tab, and they have selected 'Currently Importing', it should call a method GetNotImportedFiles() every n seconds, the method then calls the SP and binds the DataSet. </p>
  
  <p>Obviously, I need a timer which will do this every n seconds but I need it to execute the method as a background worker but communicate with the UI thread to update the DataGridView.</p>
  
  <p>If you need any code, please ask.</p>
  
  <p>UPDATE: I have implemented a timer but it never seems to hit the method for timerTick?</p>
  
  <p>In my designer I have the code:</p>
  
  <pre><code>this.refreshTimer.Interval = 1000;
  this.refreshTimer.Tick += new System.EventHandler(this.refreshTimer_Tick);
  </code></pre>
  
  <p>My understanding is that refreshTimer_Click should be called every 1 second. But I have a breakpoint in the code that is never hit?</p>
  
  <pre><code>private void refreshTimer_Tick(object sender, EventArgs e)
      {
          if (searchComboBox.Text.Equals("Currently Importing"))
          {
              try
              {
                  DataSet temp = EngineBllUtility.GetNotImportedFiles(connectionString);
                  if (temp != null)
                      importFileGridView.DataSource = temp.Tables[0];
              }
              catch (Exception ex)
              {
                  MessageBox.Show(ex.Message);
              }
          }
      }
  </code></pre>