multithreading - When do I need synchronize in TThread? -
i know need synchronize (yourprocedure) set e.g. label's text. about:
- reading label's text.
- toggle/set label's enabled property.
- call other labels procedures/functions (e.g. onclick event).
is there easy rule know/remember when need use synchronize?
ps.: synchronize similar postmessage/sendmessage?
easy rule of thumb: any access vcl ui components needs synchronized. includes both reading , writing of ui control properties. win32 uis, notably dialogs messagebox() , taskdialog(), can used directly in worker threads without synchronizing.
tthread.synchronize() similar sendmessage() (in fact, used implemented using sendmessage() internally in delphi 5 , earlier). tthread.queue() similar postmessage().
Comments
Post a Comment