title: How to display wait message while application is working with database?
body: <p>How to display wait message while my windows application is working with database.</p>
  
  <p>the problem is when i display the message "Please wait..." application does not responds till it completes database operations.</p>
  
  <p>i have simple function which interact with db while it is executing i wanted to display a message like "Please wait..." </p>
  
  <p>But my application should not hang and must respond to user interaction.</p>
  
  <p>this is my function.</p>
  
  <pre><code>         public void getReleaseInfo(Label lblDbVersion)
              {
                  if (gc.logger.IsInfoEnabled)
                      gc.logger.Info("getReleaseInfo - Method Start");
  
                  string l_sConfigPath = gc.APP_CONFIG_FILE_PATH;
                  var element = XDocument.Load(l_sConfigPath).Descendants("configuration").Descendants("connectionStrings");
                  if (element != null)
                  {
                      foreach (var item in element.Elements("add"))
                      {
                          gc.APP_CONNECTIONSTRING = (string)item.Attribute("connectionString");
                      }
                  }
                  try
                  {
                      m_oConn = new SqlConnection(gc.APP_CONNECTIONSTRING);
                      m_oConn.Open();
                      using (SqlDataAdapter l_oDA = new SqlDataAdapter(gc.SP_GETRELEASEINFO, m_oConn))
                      {
                          l_oDA.SelectCommand.CommandType = CommandType.StoredProcedure;
                          using (DataSet l_oDS = new DataSet())
                          {
                              l_oDA.Fill(l_oDS);
                              if (!l_oDS.HasErrors)
                              {
                                  if (l_oDS.Tables[0].Rows.Count &gt; 0)
                                  {
                                      lblDbVersion.Text = string.IsNullOrEmpty(l_oDS.Tables[0].Rows[0]["ReleaseInfo"].ToString()) ? "Release information not available" : l_oDS.Tables[0].Rows[0]["ReleaseInfo"].ToString();
                                  }
                              }
                          }
                      }
                  }
                  catch (Exception ex)
                  {
                      tsslDbError.ForeColor = System.Drawing.Color.Red;
                      lblDbVersion.Text = "iReg Release Information Not Available";
                      tsslDbError.Text = "Unable to connect with iReg Database, Please contact iReg Suppot!";
                      btnBrowse.Enabled = false;
                      btnBackup.Enabled = false;
                  }
                  finally
                  {
                      if (m_oConn != null)
                      {
                          if (m_oConn.State == ConnectionState.Open)
                              m_oConn.Close();
  
                          m_oConn.Dispose();
                      }
                  }
  
                  if (gc.logger.IsInfoEnabled)
                      gc.logger.Info("getReleaseInfo - Method End");
              }
  </code></pre>
  
  <p>and from here i am calling that function.</p>
  
  <pre><code>            try
              {
                  lblDbVersion.Text = string.Empty;
                  this.tsslDbError.ForeColor = System.Drawing.Color.Black;
                  tsslDbError.Text = "Please wait... While connecting to iReg Database.";
                  getReleaseInfo(lblDbVersion);   
                  this.tsslDbError.Text = string.Empty;
  
              }
              catch (Exception ex)
              {                   
                  this.tsslDbError.ForeColor = System.Drawing.Color.Red;
                  lblDbVersion.Text = "iReg Release Information Not Available";
                  this.tsslDbError.Text = "Unable to connect with iReg Database, Please contact iReg Suppot!";
                  btnBrowse.Enabled = false;
                  btnBackup.Enabled = false;
              }
              finally 
              {
  
              }
              if (gc.logger.IsInfoEnabled)
                  gc.logger.Info("btnIregPath_Click - Method End");
          }
  </code></pre>