Click here to Skip to main content
15,904,153 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to get a huge struct array? Pin
Stuart Dootson2-Apr-09 21:19
professionalStuart Dootson2-Apr-09 21:19 
GeneralRe: How to get a huge struct array? Pin
jebbe3-Apr-09 20:28
jebbe3-Apr-09 20:28 
AnswerRe: How to get a huge struct array? Pin
Iain Clarke, Warrior Programmer3-Apr-09 1:51
Iain Clarke, Warrior Programmer3-Apr-09 1:51 
GeneralRe: How to get a huge struct array? Pin
Niklas L3-Apr-09 2:58
Niklas L3-Apr-09 2:58 
GeneralRe: How to get a huge struct array? Pin
Iain Clarke, Warrior Programmer3-Apr-09 3:13
Iain Clarke, Warrior Programmer3-Apr-09 3:13 
GeneralRe: How to get a huge struct array? Pin
jebbe3-Apr-09 20:49
jebbe3-Apr-09 20:49 
JokeRe: How to get a huge struct array? Pin
Niklas L6-Apr-09 22:34
Niklas L6-Apr-09 22:34 
GeneralRe: How to get a huge struct array? Pin
Iain Clarke, Warrior Programmer6-Apr-09 22:40
Iain Clarke, Warrior Programmer6-Apr-09 22:40 
GeneralRe: How to get a huge struct array? Pin
Niklas L6-Apr-09 23:15
Niklas L6-Apr-09 23:15 
AnswerRe: How to get a huge struct array? Pin
CPallini3-Apr-09 3:01
mveCPallini3-Apr-09 3:01 
GeneralRe: How to get a huge struct array? Pin
jebbe3-Apr-09 20:52
jebbe3-Apr-09 20:52 
AnswerRe: How to get a huge struct array? Pin
sashoalm4-Apr-09 2:55
sashoalm4-Apr-09 2:55 
Questionstrange character Pin
ruthlesspker2-Apr-09 15:17
ruthlesspker2-Apr-09 15:17 
AnswerRe: strange character Pin
Luc Pattyn2-Apr-09 16:44
sitebuilderLuc Pattyn2-Apr-09 16:44 
AnswerRe: strange character Pin
«_Superman_»2-Apr-09 19:10
professional«_Superman_»2-Apr-09 19:10 
GeneralRe: strange character Pin
ruthlesspker2-Apr-09 21:33
ruthlesspker2-Apr-09 21:33 
GeneralRe: strange character Pin
krmed3-Apr-09 0:37
krmed3-Apr-09 0:37 
QuestionglDrawPixels help Pin
Member 33753342-Apr-09 12:39
Member 33753342-Apr-09 12:39 
AnswerRe: glDrawPixels help Pin
Cedric Moonen2-Apr-09 20:16
Cedric Moonen2-Apr-09 20:16 
GeneralRe: glDrawPixels help Pin
Member 33753343-Apr-09 3:05
Member 33753343-Apr-09 3:05 
QuestionNtfsDisable8dot3NameCreation does not take its effect for short path generation Pin
tom groezer2-Apr-09 10:13
tom groezer2-Apr-09 10:13 
AnswerRe: NtfsDisable8dot3NameCreation does not take its effect for short path generation Pin
tom groezer3-Apr-09 1:19
tom groezer3-Apr-09 1:19 
QuestionRaise thread safe event Pin
tadams11382-Apr-09 9:56
tadams11382-Apr-09 9:56 
AnswerRe: Raise thread safe event Pin
tadams11382-Apr-09 11:24
tadams11382-Apr-09 11:24 
AnswerRe: Raise thread safe event Pin
Roger Stoltz2-Apr-09 11:58
Roger Stoltz2-Apr-09 11:58 
tadams1138 wrote:
does anyone know the best way in an MFC ActiveX control to raise an event on another thread?


There's only one correct way, even though it may look differently depending on the implementation: marshalling.

"Raising an event" in fact means calling an interface implemented by the client from the server. The same rules apply as when calling an interface implemented by the server from a client.
As always, when crossing apartment boundaries you have to marshal the interface. Since the secondary thread in your case is another apartment, you have to marshal the client interface to the secondary apartment.
You also have to make sure you set up the secondary apartment properly by calling ::CoInitialize() from that thread before doing any COM related stuff and consequently call ::CoUninitialize() before exiting the thread.

Marshalling the client interface, or the "event sink", can be done using the GIT (Global Interface Table). You add an interface to the GIT that you want to marshal and get it in the apartment where you want to use it. When you're done with the interface you revoke it from the GIT.
Read more about the GIT here[^].


"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown


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.