Question on Coinitialize

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Ray Mond

Question on Coinitialize

Post by Ray Mond » Thu 07 Jul 2005 12:43

I have a service application, that creates a thread (A) to perform some business logic, which in turn creates thread (B), that holds a TMSConnection and TMSQuery. Thread (B) will execute whatever query thread (A) requires, and when done, goes into a suspended state until (A) either terminates it or gives it another query.

The problem now is that sometimes, (B) never returns from running its query. Using Profiler, I can see that the query completed on SQL Server's side, but in my app, the Execute method never returns.

Now, in thread (A), I need to call CoInitializeEx(nil, COINIT_MULTITHREADED). In thread (B), do I still need to call CoInitialize(nil), though it does not seem to make a difference.

Any suggestions? Thanks.

Ray Mond

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Thu 07 Jul 2005 13:20

> The problem now is that sometimes, (B) never returns from running its query

Please send us complete small sample to demonstrate it and include
script to create server objects.

> Now, in thread (A), I need to call CoInitializeEx(nil, COINIT_MULTITHREADED).
> In thread (B), do I still need to call CoInitialize(nil), though it does not seem to make
> a difference.

Usually you must call CoInitialize or CoInitializeEx in that thread where the connection is.

Post Reply