by Kambiz » May 24th, 2011, 9:39 pm
First of all, you should use TFindFile in threaded mode, so that you can pause or resume its thread.
An easy but unsafe solution is pausing/resuming the thread object. The change of deadlock is high, and besides that Pause and Resume methods of TThread class are deprecated now.
A better solution is using a synchronization object to put the thread in the wait state whenever is needed. Usually, the pause is needed when the user should do some actions regarding the last found item. So, it's better we save time and keep searching while the user is making a decision. We only have to really pause the search when another item is found.
You will find a sample implementation of the above in the attached file.
- Attachments
-
- FindFile_PauseResume.zip
- Pausing/Resuming TFindFile search using an event object.
- (2.34 KiB) Downloaded 225 times
Kambiz