Click to See Complete Forum and Search --> : Multithreading in DCOM


May 6th, 1999, 07:22 AM
Server:
I have a STA DCOM Server with an interface say IServer which export a method say StartPlay().

Client:

Now I would like to call this method in two threads, but failed. The way I am doing is like this -

MyProject()
{
// Store the interface pointer in m_pServer from calling CoCreateInstanceEx()
HRESULT hRes = CoMarshalInterThreadInterfaceInStream(IID_IServer, m_pServer, (LPSTREAM *) & m_pStream);

// Create the thread two times
for(int i=0; i<2; i++)
{
CreateThread(NULL, 0, StartPlayWrapper, NULL, 0, &dwThreadID);
}

}

StartPlayWrapper()
{
HRESULT hRes = CoInitialize(NULL);
IServer *pServer = NULL;
hRes = CoUnMarshalInterface( m_pStream, IID_IServer, (void **)&pServer);

// Till here no problem comes, but calling the StartPlay() method is not envoking.
// No Error message comes

pServer->StartPlay(); // Ignore this statament while debugging.
}
I am releasing the stream.

Could any of you please help me to encounter this problem?? Its very urgent for me.
The document says to use Messageloop. What's should be do to come out from this problem.

Thanks in advanced
Santa