views:

214

answers:

2

Hi,

I can acheive the same functionality by both PostMessage and AfxBeginThread ( calling asynchrously ) So where lies the the difference between PostMessage and AfxBeginThread?

+7  A: 

AfxBeginThread starts a whole new thread in your function.

PostMessage is using the main message loop of the process, so if you use PostMessage to do a long operation, you will freeze the message loop, making the GUI non responsive till you finish the operation.

Am
A: 

Posting messages is a very underrated thread synchronisation method in Windows programming. I almost exclusively use it as opposed to other thread communication mechanisms. But this is not what you are asking, I think.

I would be asking the question of whether or not your processing is going to be long enough to warrant its own thread. If the answer is no then keep it simple and just do it in the same thread.

Igor Zevaka