--- In [email protected], "swzoh" <sean...@...> wrote:
>
> --- In [email protected], "entropyreduction"
> <alancampbelllists+yahoo@> wrote:
> >
> > Investigations continue. Wanna see the thread code?
> I'd like to, although I'm not sure if I'm helpful here. Maybe Bruce could
> also take a look.
> Actually I'm more interested in the main-thread code as I failed to think of
> a reason why it didn't work. Remember? We already succeeded without a problem
> to call IActiveDesktop via dll.call() which just uses the main thread.
Okay, here goes:
the dll service does this:
//////////////////////////////////////////////////////////////////////////
the dll service does this:
StringArg strArgResult;
resultType aResult = g_pCComManager->createObject(PP_PLUGIN_ARG1,
&strArgResult);
g_pCComManager is a pointer to a singleton CComManager object
//////////////////////////////////////////////////////////////////////////
resultType
CComManager::createObject(IN LPCTSTR pszComName,
OUT StringArg* strArgResult)
{
if (!m_pDictObjects->bThereIsFreeSpace())
return resultErrCantStoreObj;
//get singleton
COMactionCreate* pCOMactionCreate =
COMactionCreate::getInstance(this);
//set it up
pCOMactionCreate->init(pszComName, strArgResult);
//set the single pointer to an action object
m_pCOMactionAbstract = pCOMactionCreate;
//make sure thread is running
if (!startThread())
return resultOK;
//reset the returning event
ResetEvent(m_hEvtActionDone);
//kick the thread into action
SetEvent(m_hEvtActionReq);
//wait for it to come back
WaitForSingleObject(m_hEvtActionDone, INFINITE);
ResetEvent(m_hEvtActionDone);
aResult = m_pCOMactionAbstract->m_resultType;
m_pCOMactionAbstract = NULL;
return aResult;
}
//////////////////////////////////////////////////////////////////////////
The thread looks like this:
DWORD WINAPI CComManager::COMActivityThread(LPVOID info)
{
USES_CONVERSION;
BOOL bKeepGoing = TRUE;
HRESULT hr = CoInitialize(NULL);
if((FAILED(hr)))
return 0;
while (bKeepGoing)
{
WaitForSingleObject(m_hEvtActionReq, INFINITE);
_ASSERT(m_pCOMactionAbstract);
bKeepGoing = m_pCOMactionAbstract->doIt();
//only COMactionReleaseAll::go() returns false
ResetEvent(m_hEvtActionReq);
if (bKeepGoing) //
SetEvent(m_hEvtActionDone);
}
CoUninitialize(); // TO DO GETS STUCK HERE
SetEvent(m_hEvtActionDone);
return 0;
}
//////////////////////////////////////////////////////////////////////////