multithreading - When do I need synchronize in TThread? -


i know need synchronize (yourprocedure) set e.g. label's text. about:

  1. reading label's text.
  2. toggle/set label's enabled property.
  3. 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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -