To clear the issue, I have written another sample program to show how to use BackgroundWorker component to pass strings and objects from the worker thread to the main VCL thread.
In this sample, no synchronization is involved and the worker thread never waits for the main VCL thread. In this way a worker thread can do the time consuming tasks smoothly, and other threads (including the main thread) can not interrupt or slow down it.
This sample is a thumbnail viewer. After selecting an image folder, the background worker thread does the following tasks:
- Searches for image files in the folder
- Creates thumbnail of each image
- Sends filename and thumbnail (Bitmap) of each image to the main VCL thread to be displayed on a listbox