title: Is it better to use TThread's "Synchronize" or use Window Messages for IPC between main and child thread?
body: <p>I have a rather simple multi-threaded VCL gui application written with Delphi 2007. I do some processing in multiple child threads (up to 16 concurrent) that need to update a grid control on my main form (simply posting strings to a grid). None of the child threads ever talk to each-other.</p>
  
  <p>My initial design involved calling <a href="http://www.eonclash.com/Tutorials/Multithreading/MartinHarvey1.1/Ch3.html#The%20Delphi%20solution:%20TThread.Synchronize." rel="noreferrer">TThread's "Synchronize"</a> to update the grid control form within the currently running thread. However, I understand that calling Synchronize essentially executes as if it is the main thread when called. With up to 16 threads running at once (and most of the child thread's processing takes from &lt; 1 second to ~10 seconds) would Window Messages be a better design?</p>
  
  <p>I've gotten it working at this point where the child thread posts a windows message (consisting of a record of several strings) and the main thread has a listener and simply updates the grid when a message is received.</p>
  
  <p>Any opinions on the best method for IPC in this situation? Window messages or 'Synchronize'?</p>
  
  <p>If I use window messages, do you suggest wrapping the code where I post to the grid in a TCriticalSection (enter and leave) block? Or will I not need to worry about thread safety since I'm writing to the grid in the main thread (although within the window message handler's function)?</p>