PDA

View Full Version : Is it safe to sendEvent to MainWIndow from thread?and postEvent?



coralbird
23rd July 2006, 04:08
I transfer the MainWindow's pointer to a thread,and in the thread I call send event to this
window.In fact, after a while sendEvent don't return.I know in thread had better not call any GUI funtion, and i know sendEvent only return after the message is processed too.
Thanks a lot!

wysota
23rd July 2006, 07:02
SendEvent is not thread safe, as it is a synchronic call. PostEvent should work fine.

coralbird
24th July 2006, 01:40
SendEvent is not thread safe, as it is a synchronic call. PostEvent should work fine.
Thanks.
Is it certain that the event that sent by postEvent can be processed?what I mean is "message lost". Is it processed as the sequence that events be sent?
Thanks a lot!

wysota
24th July 2006, 01:59
Is it certain that the event that sent by postEvent can be processed?
Yes, provided that you posted it correctly.


what I mean is "message lost".
Maybe it got lost somewhere during the process of posting? Did you remember to create it on heap? Could you show the lines where you post the event? If it is a custom event, did you reimplement the method for handling custom events in the target widget?


Is it processed as the sequence that events be sent?
In general -- yes.

coralbird
26th July 2006, 07:06
Maybe it got lost somewhere during the process of posting?

In fact I don't find message lost , I just worry if postEvent is reliable to use.And I prepare to do strict test .



Did you remember to create it on heap? Could you show the lines where you post the event? If it is a custom event, did you reimplement the method for handling custom events in the target widget?

All of the answer is sure.Now the code is working fine.
Thank wysota again!