title: Connection Pooling with Task Parallel Library in .NET 4
body: <p>I Have exe which is running on the server continuously for batch processing of thousands of file, data from the file is inserted into the database for all file same connection string is being used. I Have made use of TPL of .net 4 for improving performance. Basic flow of the code as follows since i dont know much about the connection pooling will following approach will lead me into trouble Please suggest. Thanks.</p>
  
  <p>Flow:
  1. create array of task (around 50 Task for 50 files)
  2. Add each Task to task of Array
  3. wait for All task and repeat for next 50 files</p>
  
  <pre><code>                   Task[] taskArry = new Task[50];
                      for (int i = 0; i &lt; 50; i++)
                      {
                          taskArry[i]=(Task.Factory.StartNew(() =&gt;                          InstanceDataObject.InserData()));
  
                          //var t2 = Task.Factory.StartNew(() =&gt; InsertData());
                      }
  
                           Task.WaitAll(taskArry);
  </code></pre>
  
  <p><strong>Key point to note here is that i am initiating my connection object for each task in InsertData() methode as each task must be performed with transaction so 50 connection are created for 50 Task will this impact the performace?</strong></p>
  
  <pre><code>    internal static void InserData(string insPath, int filingId)
          {
               try
              {
                 DataAccess dataAcess = new DataAccess(true);
                 // insert operation here
                 dataAcess.CommitTransaction();
              }
              finally
              {
                   dataAcess.Dispose();
                  _dbmanager = null;
  
              }
  }
  </code></pre>
  
  <p>I am using connection string like this
  "Server=Test;User id=user;Password=@1234;database=test"
  as default connection pooling is enabled for conection string i Have not set any parameters related to pooling. <strong><code>Shall i have to set the parameter regarding connection pooling?</code></strong> for my scenario</p>