I have an application that runs multiple concurrent background processes to insert data into the database using the Enterprise Library's Data Access application block. Each of the background thread uses the DatabaseFactory.CreateDatabase passing in the same database instance name. The following is the snippet of code that retrieves the database and command object:
Microsoft.Practices.EnterpriseLibrary.Data.Database database = DatabaseFactory.CreateDatabase(this.DatabaseInstanceName);
DbCommand commandObj = database.GetSqlStringCommand(statement);
I'm finding that this is not thread safe and I'm getting errors due to the values getting mixed up across the threads. How should I handle this to ensure that it is thread safe?
thanks in advance!