Click here to Skip to main content
15,608,388 members

Comments by Bob Ciora (Top 1 by date)

Bob Ciora 6-Apr-11 6:47am View    
[code]PostMessage[/code]'ing a heap-allocated pointer is fine as long as the target knows it and cleans up the pointer in the handling routine. I do it all the time (in MFC) when, e.g. a Dialog class gets information outside the normal windows message loop. This asynchronous method wraps up the data in some heap-allocated structure, then Posts the data to itself so that it can be processed synchronously.

A problem with [code]SendMessage[/code]'ing something (which is asynchronous) is that if you're doing the [code]SendMessage[/code] from a thread that is *not* the main message loop, you run the risk of locking up that main loop. Of course, that depends more on the complexity of the app.