On 01.11.2010 09:57, Graeme Geldenhuys wrote:
Hi,

What is the rules regarding a TThread descendants and public events. I
created a thread that has OnXXX events. These events are triggered in the
Execute method of that event.

Now my main event (which manages the application GUI) hooked into these
event by implementing event handlers. Those event handlers take the data
from the event and updates a StringGrid.

Is this safe to do?

Must the thread execute the event via a Synchronize() call, or is it now
needed? The reason I'm not sure here, is because the thread doesn't actuall
update the GUI component (stringgrid in this example) directly, it just
triggers the event.

The code is still run in the thread's context, no matter whether the code is in your TThread class or e.g. a global procedure. So you should use Synchronize to trigger the event.

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to