Asynchronous Monikers, thread bug?
Hi,
I'm trying to use asynchronous monikers to download files. I've implemented
CIEStatusCallback that derives from the IBindStatusCallback interface, and I
initiate a download process the following way:
IStream* pstm = NULL;
IMoniker* m_pmk;
IBindCtx* m_pbc;
IBindStatusCallback* m_pbsc = new CIEStatusCallback();
hr = CreateURLMoniker(NULL, tcwCanonicalizedUrl, &m_pmk); // S_OK
hr = CreateBindCtx(0, &m_pbc); // S_OK
hr = RegisterBindStatusCallback(m_pbc,m_pbsc, 0, 0L); // S_OK
hr = m_pmk->BindToStorage(m_pbc, 0, IID_IStream, (void**)&pstm);
// MK_S_ASYNCHRONOUS
The CIEStatusCallback has been tested with URLOpenStream API, and it should
be correct. CIEStatusCallback::GetBindInfo() returns BINDF_ASYNCHRONOUS
|BINDF_ASYNCSTORAGE | BINDF_PULLDATA.
I believed that I found a bug (or at least some kind of problem) in
asynchronous URL monikers. If the above piece of code is called from the
program window procedure (i.e. the WM_COMMAND handler for a button), it
works fine. However, if I put this piece of code in a thread, it stopped
working.
If I put the exact same code in a thread created by CreateThread,
CIEStatusCallback::QueryInterface, ::GetBindInfo will be called as expected.
But the downloading process didn't start after then. It appears that being
called from a thread makes it impossible for the asynchronous moniker to
create its own thread.
Could someone confirm this for me? Any suggestions?
Best regards,
--
He Shiming
date: Thu, 28 Jul 2005 15:55:39 +0800
author: He Shiming mailbill(NOSPAM)@21cn.com.nospam