title: Splash Screen for loading data into ListView C#
body: <p>I created an application which loads data into a ListView by executing a procedure that is stored in SQL Server. The procedure takes some time to execute, when I click the button on application to execute the procedure my application just freeze until the data is loaded in the ListView.</p>
  
  <p>How can I create a splash screen that loads when I press the button until the data is populated in the List View?</p>
  
  <p>I appreciate any feedback.</p>
  
  <pre><code>public async Task&lt;ListView&gt; GetDataAsync()
          {
               var dt = new ListView();
               //var cn = @"Your Connection String";
               //var cmd = @"SELECT * FROM Category";
               //var da = new SqlDataAdapter(cmd, cn);
               SqlConnection conn = new SqlConnection();
               conn.Open();
  
               SqlCommand cmd = new SqlCommand("[Loyalty_Swipe]", conn);
               cmd.CommandType = CommandType.StoredProcedure;
               cmd.CommandTimeout = 0;
               SqlDataReader reader;
  
               cmd.Parameters.AddWithValue("@StartDate", txtStartDate.Text);
               cmd.Parameters.AddWithValue("@EndDate", txtEndDate.Text);
               cmd.Parameters.AddWithValue("@CustomerID", txtCustID.Text);
               reader = cmd.ExecuteReader();
               metroListView1.Items.Clear();
  
               await Task.Run(() =&gt;
               {
                   while (reader.Read())
                   {
  
                       metroListView1.Columns[0].Text = "Date";
                       metroListView1.Columns[1].Text = "Store Code";
       ListViewItem listview = new   ListViewItem(reader["Date"].ToString());
                       listview.SubItems.Add(reader["StoreCode"].ToString());
                       listview.SubItems.Add(reader["StoreName"].ToString());
                       listview.SubItems.Add(reader["TillNumber"].ToString());
                       listview.SubItems.Add(reader["TranNumber"].ToString());
                       listview.SubItems.Add(reader["Amount"].ToString());
                       listview.SubItems.Add(reader["Discount"].ToString());
                    listview.SubItems.Add(reader["ProcessedFlag"].ToString());
                   listview.SubItems.Add(reader["Processed Date"].ToString());
                   metroListView1.Items.Add(listview);
  
  
  
  
                   };
               });
               conn.Close();
               pbLoad.Hide();
               btnExport.Enabled = true;
               return dt;
          }
  </code></pre>