Connection Manager and multi-threaded calls to Save()

Old forum URL: forums.lhotka.net/forums/t/9443.aspx

snakebyteme posted on Friday, August 27, 2010

Our BOs use the connection manager class.

Our processing is mainly client side in the code and each object has no dependency on the other object being processed. To speed up the time it takes to process 2000+ objects, we are executing 8 processing threads.

When we try to do parallel processing of 8 business objects at a time, we get deadlock issues from the DB since the connection manager is giving the same connection for each thread. Is there a way for the ConnectionManager to be thread aware and store a structure like (ThreadID,ConnectionString, Connection, Counter) ?

Most of our BOs have similar code like this to do Inserts into the DB:

Private Sub AddUser() Using ctx = ConnectionManager(Of SqlClient.SqlConnection).GetManager(DAL.SQL.DBName) Using db As New SQL(ctx.Connection)