Click here to Skip to main content
15,902,922 members
Home / Discussions / COM
   

COM

 
GeneralRe: default properties on COM interfaces Pin
Mil101-Jul-03 18:59
Mil101-Jul-03 18:59 
GeneralRe: default properties on COM interfaces Pin
Dave Bryant2-Jul-03 10:35
Dave Bryant2-Jul-03 10:35 
GeneralRe: default properties on COM interfaces Pin
Mil102-Jul-03 18:46
Mil102-Jul-03 18:46 
GeneralRe: default properties on COM interfaces Pin
Dave Bryant2-Jul-03 18:49
Dave Bryant2-Jul-03 18:49 
GeneralRe: default properties on COM interfaces Pin
Mil102-Jul-03 21:56
Mil102-Jul-03 21:56 
GeneralRe: default properties on COM interfaces Pin
Dave Bryant3-Jul-03 8:55
Dave Bryant3-Jul-03 8:55 
GeneralRe: default properties on COM interfaces Pin
Vi23-Jul-03 21:43
Vi23-Jul-03 21:43 
GeneralSending events Pin
act_x30-Jun-03 4:42
act_x30-Jun-03 4:42 
I am working in a framework in my COM server where I have a thread . From this thread I need to send events out of the Server which I am not able to do normally . What should I be doing in order to be able to send out events !


Related article in MSDN is

Events and threads
The good doctor alluded to problems he was having with events and threads earlier.

Here's the basic rule: Unless you do something special (more on this later), you always have to fire your events from the same thread that called IConnectionPoint::Advise. You may not normally start another thread and fire events from that thread. Why? Well, to fire an event means that you call into another object using an interface pointer.

But, in COM, you are never allowed to pass interface pointers between threads; you must marshall them instead. This is not terribly difficult to do, even though it involves calling the API with the world's longest name: CoMarshalInterThreadInterfaceInStream. (Perhaps it's named for a small town in Wales.)

You pass the stream pointer to the other thread (guaranteed to work in this special case) and call CoGetInterfaceAndReleaseStream in the new thread to get a marshalled interface pointer. Unfortunately, ATL's event firing implementation doesn't marshall the interface pointers, so it'll take some work to fire events from another thread.

In two common cases, this isn't an issue. If you're firing the event in response to a Windows message, such as a mouse button down message, you'll be okay. You'll be running on the same thread you were created on when you received the message.

Or, in our example, we fire an event in response to a method call. Again, this is safe, because the method will be called on the same thread you were created on.

It's only when you explicitly create a thread yourself (such as to sleep, or do some background processing) that firing events from the newly created thread becomes difficult.




So Do I have to Marshall the Interface to the COM server or all the IConnectionPoint Interfaces ?
GeneralWhen whould this occur?... Pin
CherezZaboro30-Jun-03 3:37
CherezZaboro30-Jun-03 3:37 
GeneralRe: When whould this occur?... Pin
Vi230-Jun-03 4:34
Vi230-Jun-03 4:34 
GeneralRe: When whould this occur?... Pin
CherezZaboro30-Jun-03 5:48
CherezZaboro30-Jun-03 5:48 
GeneralRe: When whould this occur?... Pin
Vi21-Jul-03 1:51
Vi21-Jul-03 1:51 
GeneralOleCreateFromFile and OleCreatePictureIndirect Pin
Florin Ochiana28-Jun-03 22:12
Florin Ochiana28-Jun-03 22:12 
GeneralExcel COM Add-In Pin
Anonymous27-Jun-03 13:09
Anonymous27-Jun-03 13:09 
Generalvariant data type.. Pin
safee ullah26-Jun-03 19:46
safee ullah26-Jun-03 19:46 
GeneralRe: variant data type.. Pin
Fredrik Skog26-Jun-03 20:19
Fredrik Skog26-Jun-03 20:19 
GeneralRe: variant data type.. Pin
Vi227-Jun-03 0:56
Vi227-Jun-03 0:56 
GeneralCOM/ASP Pin
Kant26-Jun-03 5:12
Kant26-Jun-03 5:12 
GeneralRe: COM/ASP Pin
Mil1030-Jun-03 20:38
Mil1030-Jun-03 20:38 
Generalconverting an idl file to .h Pin
si_6926-Jun-03 0:47
si_6926-Jun-03 0:47 
GeneralRe: converting an idl file to .h Pin
valikac26-Jun-03 5:30
valikac26-Jun-03 5:30 
GeneralRe: converting an idl file to .h Pin
Vi227-Jun-03 1:24
Vi227-Jun-03 1:24 
GeneralProblem in passing structure pointer via Interface Pin
mpb24-Jun-03 20:48
mpb24-Jun-03 20:48 
GeneralRe: Problem in passing structure pointer via Interface Pin
Aravinthan25-Jun-03 3:03
Aravinthan25-Jun-03 3:03 
GeneralRe: Problem in passing structure pointer via Interface Pin
mpb29-Jun-03 19:01
mpb29-Jun-03 19:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.