My multithreaded application has a GUI with a log screen (TMemo box). I send messages back to the main GUI using PostMessage from the threads to update the log:
This code is incomplete.. just showing you an example of the 0 case.
a := Tstringlist.create;
if globalgetatomname(Message.LParam,s,255) > 0 then sdata := strpas(s);
case Message.WParam of
0: begin//write log
Now on the TMemo box "onchange" event I put Application.processmessage
s; Without this the GUI is frozen the entire time the log is being written too..which is frequent. However if the log is written to, to fast the application crashes. With application.processmessage
s removed it never crashes.
My question is, is there a proper way to update the GUI/Tmemo boxes and what not without using application.processmessage
s? Should I be using BeginThread to write to the log?