title: C# Interacting with Database In async way, not working.
body: <p>I just wanted to create a dummy ASP.NET MVC project where i wanted to explore more about async &amp; await.I created async methods in DB access Layer and Repository Layer and i also make sure that the action is also written in async way. I noticed that a single method takes around 7ms to execute, so logically if i call the method 3 times i also should take 7 ms or around 7ms ! But its taking about 20-23 ms. I am sure that i am doing something terribly wrong. My Code snippet goes below: </p>
  
  <p><strong>DATA ACCESS LAYER:</strong></p>
  
  <pre><code>    public async Task&lt;DataTable&gt; DtGetAllCustomers()
      {
          await Task.Run(() =&gt;
          {
              _dtCustomer = new DataTable();
              _connectionString = Repo.GetConnString();
              _spName = "spGetCus";
              _spParameters = new SqlParameter[]
              {
              new SqlParameter("@QryOption",1)
              };
              using (var conn = new SqlConnection(_connectionString))
              {
                  using (var cmd = new SqlCommand())
                  {
                      cmd.Connection = conn;
                      cmd.CommandText = _spName;
                      cmd.Parameters.AddRange(_spParameters);
                      cmd.CommandType = CommandType.StoredProcedure;
                      conn.Open();
  
                      using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                      {
                          da.Fill(_dtCustomer);
                          conn.Close();
                          da.Dispose();
                      }
                  }
              }
  
          });
  
          return _dtCustomer;
      }
  </code></pre>
  
  <p><strong>REPOSITORY:</strong></p>
  
  <pre><code> public async Task&lt;List&lt;CustomerModel&gt;&gt; GetAllCustomers()
              {
                  _dtCustomer = await _customerDal.DtGetAllCustomers();
                  List&lt;CustomerModel&gt; allCustomers = new List&lt;CustomerModel&gt;();
                  return allCustomers = (from DataRow row in _dtCustomer.Rows
                                         select new CustomerModel
                                         {
                                             CustomerId = (int)row["CustomerId"],
                                             CustomerName = (string)row["CustomerName"]
                                         }).ToList();
              }
  </code></pre>
  
  <p><strong>ACTION:</strong>  </p>
  
  <pre><code>public async Task&lt;ActionResult&gt; Index()
          {
              var watch = System.Diagnostics.Stopwatch.StartNew();
              List&lt;CustomerModel&gt; model = new List&lt;CustomerModel&gt;();
              CustomerRepo2 aa = new CustomerRepo2();
              await aa.GetAllCustomers();
              await aa.GetAllCustomers();
              await aa.GetAllCustomers();
              watch.Stop();
              var elapsedMs = watch.ElapsedMilliseconds;
              ViewBag.time = elapsedMs;
              return View();
          }
  </code></pre>