RAD Studio
ContentsIndex
PreviousUpNext
Writing Cleanup Code
To clean up after your thread finishes executing

  1. Centralize the cleanup code by placing it in the OnTerminate event handler. This ensures that the code gets executed.
  2. Do not use any thread-local variables, because OnTerminate is not run as part of your thread.
  3. You can safely access any objects from the OnTerminate handler.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!