Writing Cleanup Code

From RAD Studio
Jump to: navigation, search

Go Up to Building a Multithreaded Application


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.

See Also