is it not possible at all to use an existing MSConnection in
Posted: Wed 10 Nov 2010 08:52
I am succesfully implementing background threads that use a dedicated connection.
I have only one problem, since I am connecting to the DB inside the thread, I lose a lot of time in estabilishing the connection and a very little time to execute the thread:
Ok, it is a background thread, but I lose 2 extra seconds, since in some cases I need to run many background threads and wait for all of them to be completed bfore continuing anyway those "2 seconds" can make a difference in speed.
Is it a way I can pass an already existing connection or am I forced to call TMSConnection.Connect INSIDE the thread?
I have only one problem, since I am connecting to the DB inside the thread, I lose a lot of time in estabilishing the connection and a very little time to execute the thread:
Code: Select all
procedure TSDACBackgroundThread.Execute;
begin
// coinitialize part
FData.MSConnection.Connect; // takes "2 seconds"
FData.MSQuery.Execute; // takes "5 milliseconds"
FData.MSConnection.Disconnect;
end;Is it a way I can pass an already existing connection or am I forced to call TMSConnection.Connect INSIDE the thread?