Re: ADO in multithreaded: Application Verifier (with WinDbg) gives "Invalid Handle" at the end of my application
- From: "Dvorak" <goran1978@xxxxxxxxx>
- Date: 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:
/*Main thread*/
HRESULT hr = CoInitializeEx(NULL,COINIT_MULTITHREADED); // setup COM
lib
if(FAILED(hr))
debug (" Multithread initialization failed");
//lot of code//
m_hDrvThread = CreateThread( NULL, NULL, ThreadFnc, (LPVOID)poi, 0,
&dwId);
/*Function for the thread which uses ADO*/
HRESULT hr = CoInitializeEx(NULL,COINIT_MULTITHREADED); //
setup COM lib
if(FAILED(hr))
debug (" Multithread initialization failed");
//code that I wrote on the first post
CoUninitialize();
/*end of Function for the thread which uses ADO*/
CoUninitialize(); //here, when debugged with Application Verifier and
WinDbg an exception with "Invalid Handle" raises
/*End of Main thread*/
.
- Follow-Ups:
- References:
- Prev by Date: Re: Referencing data column by it's name
- Next by Date: Re: Referencing data column by it's name
- 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
|