Is TCanvas thread-safe? lazarus / 8-Other ---------------------------------------------------------------------- Troodon · 2009-02-12 20:31 In Delphi, the Canvas object is thread-safe. Is it also thread-safe in Lazarus/FPC? Thanks. ---------------------------------------------------------------------- felipemdc · 2009-02-16 07:56 Just test it and see if you find any problems. If yes, then you can use TCanvas.Lock and Unlock to make operations atomical and thread-safe ---------------------------------------------------------------------- Troodon · 2009-02-16 15:59 Thank you for your response, sekel. I ran some tests, both on Win32 and Linux (Gtk2), and so far the results seem to indicate that TCanvas is "thread-safe" on Windows provided that drawing is performed in the TThread.Synchronize method, not in TThread.Execute (otherwise behavior is unpredictable). On Linux, the results are more difficult to interpret as TCanvas is apparently painted in a different way than it is on Windows. Drawing seems to be performed in a memory buffer; upon completion, the final bitmap it is copied to TCanvas. That makes drawing extremely fast on Linux but does not allow me to watch its progression. I didn't use either a Critical Section or TCanvas.Lock. ---------------------------------------------------------------------- Vincent Snijders · 2009-02-16 18:20 Quote from: Troodon on February 16, 2009, 04:59:25 pmI ran some tests, both on Win32 and Linux (Gtk2), and so far the results seem to indicate that TCanvas is "thread-safe" on Windows provided that drawing is performed in the TThread.Synchronize method, not in TThread.Execute (otherwise behavior is unpredictable).This is the case for every LCL function, not just TCanvas. QuoteOn Linux, the results are more difficult to interpret as TCanvas is apparently painted in a different way than it is on Windows. Drawing seems to be performed in a memory buffer; upon completion, the final bitmap it is copied to TCanvas. That makes drawing extremely fast on Linux but does not allow me to watch its progression.The gtk widgetset re-orders messages, so that paint messages bundled and send after all other messages.