Hi to all,
well i've a little question about interthread interface pointer marshaling
When i've a component that creates a working thread which has to fire events i've to marshal the pointer to the interface
into the new thread
What i've done till now is:
Marshal the pointer to the method interface in the new thread
and i've added a new method to the interface that has to be called only by the working thread and not by the client (VB in my case) that fires events in the client
It seems the marshaling goes right coz tha apis i called return S_OK but when i try to fire the event with the new pointer
my component crashes
Here is the code :

/* in the primal thread */
hr = CoMarshalInterThreadInterfaceInStream(__uuidof(IDialogicObj1), (IDialogicObj1*)this, &pStream);

/* in the working thread */
hr = CoGetInterfaceAndReleaseStream(ptr->pStream, __uuidof(IDialogicObj1),(void**)&pServer);

pServer->_CallOnConnected(); /* crash is here */

STDMETHODIMP CDialogicObj1::_CallOnConnected()

// TODO: Add your implementation code here
Fire_OnConnected(); /* Fires the event in the client */
return S_OK;

Whats wrong with it ?

Well i've a little doubt: should i marshal the IConnectionPoint pointer and fire event directly from the working thread ?

Tnx a lot
Posted on 2002-03-11 07:32:09 by NikDH

It's not that we don't like you, or we're all in some conspiracy of silence.

We just don't know the answers.
Posted on 2002-03-12 22:46:31 by Ernie


We just don't know the answers.

Hi ernie,
its ok man dont worry :)

Well i'm quite happy coz i found the solution :)))

For the design of my project was needed that the working thread was the one that have to fire events
That means that i've to marshal the IConnectionPoint interface that points to the VB Sink when its created and thats possible
coz of the Advise() event (in reality its a virtual method) given by the IConnectionPoint class
There its passed to me the IUnknown pointer to the VB Sink
and so i can do marshaling and take it in the working thread
When i've the right pointer to the VB Sink in the working thread
well i can call the Invoke() method and fire events

See ya
Posted on 2002-03-13 09:38:39 by NikDH