Article

From:
To:
David HAROUCHE
Subject:
Re: How threadsafe is TBitmap
Newsgroup:
embarcadero.public.delphi.graphics

Re: How threadsafe is TBitmap

David HAROUCHE wrote:

> Better use a private TBitmap to the thread, and give public access to a 
> built-shadow TBitmap of it via a property of the Thread....

That is not correct. The really confusing part is that even local TBitmap are
not thread safe unless you lock them.

This is because every TBitmap registers itself to the global BitmapCanvasList list in graphics.pas. And when the DC garbage collection FreeMemoryContexts() is called by the main thread the rug gets pulled from under you.
The Delphi VCL itself does not always lock TBitmaps in threads. Which is, for example, why TJPEGImage is not thread safe.
Jan Derk
FYI: Phrase searches are enclosed in either single or double quotes
 
 
Originally created by
Tamarack Associates
Fri, 15 Nov 2024 16:23:57 UTC
Copyright © 2009-2024
HREF Tools Corp.