Re: ADO in multithreaded: Application Verifier (with WinDbg) gives "Invalid Handle" at the end of my application
- From: "Daniel Crichton" <msnews@xxxxxxxxxxxxxxxx>
- Date: Mon, 27 Nov 2006 16:48:00 -0000
Dvorak wrote on 27 Nov 2006 01:42:02 -0800:
Stephen Howe wrote:
Thank you for answer.The following is an excerpt from the code:
::Coinitialize(NULL)
I changed the code. Now I'm using CoInitializeEx() instead of
Coinitialize(NULL):
HRESULT hr = CoInitializeEx(NULL,COINIT_MULTITHREADED); // setup
COM lib
if(FAILED(hr))
debug (" Multithread initialization failed");
The result is S_OK. Of course, the CoUninitialize() function remained
at the end of the thread function.
Invalid Handle doesn't appear at CoUninitialize() function on this
thread, but it appears at CoUnitialize() function from the main thread.
The application has a main thread where the same CoIntializeEx with the
same parameters as in code for the thread that I showed you is called.
Also, CoUninitialize() is called at the end of application on the same
main thread. So practically, instead of giving "Invalid Handle" at the
end of the thread on CoUninitialize(), now it gives at the end of
application on CoUninitialize().
CoInitializeEx isn't called on any other thread from this application.
I'll try to be as clear as possible. Here are somehow the steps for the
thread that uses ADO and the main thread which creats it:
Sorry if this sounds like a stupid suggestion, but did you switch ADO to
free-threaded? By default ADO is apartment-threaded (both-threaded), so
calls will be serialized - this is so that it can support Access/Jet which
uses a single-threaded driver. You can change ADO to free-threaded by
editing the registry, you do this using the ADOFre15.reg file located in the
C:\Program Files\Common Files\System\ADO folder.
If the database you are connecting to has a driver that support connection
pooling then trying to share a connection via threads may well result in
slower performance. It's also possible that the connection could be dropped
or the link to the server broken in some way, so you'll need to make sure
you handle this possibility too.
Dan
.
- Follow-Ups:
- References:
- ADO in multithreaded: Application Verifier (with WinDbg) gives "Invalid Handle" at the end of my application
- From: Dvorak
- Re: ADO in multithreaded: Application Verifier (with WinDbg) gives "Invalid Handle" at the end of my application
- From: Stephen Howe
- Re: ADO in multithreaded: Application Verifier (with WinDbg) gives "Invalid Handle" at the end of my application
- From: Dvorak
- ADO in multithreaded: Application Verifier (with WinDbg) gives "Invalid Handle" at the end of my application
- Prev by Date: Re: Referencing data column by it's name
- Next by Date: Re: ADO in multithreaded: Application Verifier (with WinDbg) gives "Invalid Handle" at the end of my application
- Previous by thread: Re: ADO in multithreaded: Application Verifier (with WinDbg) gives "Invalid Handle" at the end of my application
- Next by thread: Re: ADO in multithreaded: Application Verifier (with WinDbg) gives "Invalid Handle" at the end of my application
- Index(es):
Relevant Pages
|