DelphiFAQ Home Search:
General :: Programming :: Delphi
General Delphi related information.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.
Recommended links on this topic:
Featured Article

Thread-safe and not threadsafe functions in Delphi

Question:

Some Delphi functions, like format, strToDate, ... have two versions : one that is not thread-safe, and another one (with a TFormatSettings parameter) that is thread-safe.

Is there a way to forbid the use of the not thread-safe functions?

Answer:

While there is no known list of all functions that are not thread-safe, you can start building such a list and disable them by defining global constants as shown below.

With these definitions, you can still call System.Append() if you really want to and know what you're doing, but it prevents the casual use of the function.

// Undefine SYSTEM procedures:
 const
   append = 0;
   assign = 0;
   blockread = 0;
   blockwrite = 0;
   chdir = 0;
   close = 0;
 

Generated 8:01:32 on Jan 28, 2020