Delphi 2010 Seperate Exe vs Threads
Posted on 2011-10-12
I have an application developed in Delphi 2010, running on a networked PC which has to scan a large number of backup files over servers and check the modify dates. If a back up file's date changed, it must test the file to see if its corrupt, and if its OK, copy it to a common folder on one server, Task1. The newly copied file then needs to be further processed in Task 2 which involves an intense process and then updating the processed information in an SQL database. Then there is the user interface which enables a user to interact and analyse results from the SQL database, Task 3.
At the moment I have the three tasks running in a single program with Task 1 and 2 coordinated by a self made scheduler and regularly calling Application.ProcessMessages to give the user a chance to interact with the program. This works, but not very smooth.
I am thus contemplating moving the three tasks into separate threads, but I am really battling to understand the working of threads. I played with some examples, but I still can't get my own Procedures and Functions to process inside the new thread. My alternative thinking was to move the three tasks into 3 separate executables.
I would guess the thread method would be technically the right thing to do and synchronisation won't be a problem since each of the tasks just need to talk to the SQL database in them self. I thus need some sound advice as to what would be the best route and if it’s the thread route, how can I find out how these really work and how to implement it correctly.