
Why not run multiple threads / tasks and have each task do what it needs to do on one of those files. One file at a time would be the standard, lame, approach. What I have in my application, is the need to run to some code on a number (hundreds) of files. Also, I’m not going to repeat the words of so many who wrote articles and blog posts (here’s one and another) explaining what TTask is, how VCL is not thread safe and how you need to use some synchronization to update the UI of the application (being run in the main thread), how to wait for all tasks to finish their execution or how to speed up your loops using TParallel.For.Ĭancellable Tasks (in ThreadPool) Allowing Responsive UI I’m not going to list examples when multi-threading can come handy – I’m certain all this is known. The “ Using TTask from the Parallel Programming Library” from Embarcadero’s DocWiki has more than enough to get you started. I think each and every application can benefit in some way of code being executed in multiple treads. If, until “now”, you were afraid of even trying to understand how to implement parallel programming in your applications – you should not be so.



Some more time has passed, and in Delphi XE7, Parallel Programming Library (PPL) was introduced to simplify the efforts we have to invest when there are needs to have more tasks (a unit of work you need to get done) being executed at the same time / in parallel. Those “crazy” enough to venture into the world of parallel executing code aka multi-threaded applications know how (proper) writing and debugging of such applications can become frustrating (at least). The TThread class at that time was a very lightweight wrapper around the Windows CreateThread function. Quite some time has passed since working with multiple threads was introduced in Delphi (Delphi 2, way back in 1996).
