Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <code>TThread</code> class has an <code>OnTerminate</code> event available. It is triggered by the virtual <code>TThread.DoTerminate()</code> method, which is called after <code>Execute()</code> exits, regardless of whether <code>Execute()</code> exits normally or via an uncaught exception. I would suggest overriding <code>DoTerminate()</code> and have it trigger the <code>OnAbort</code> event if the <code>Terminated</code> property is True or the <code>FatalException</code> property is not nil, and to trigger the <code>OnReady</code> event otherwise.</p> <p><strong>Update</strong>: Assuming you are using <a href="http://www.torry.net/vcl/filedrv/search/mamfilescan.zip" rel="nofollow">this TmFileScan component</a>, then I suggest you make the following modifications so the <code>OnReady</code> event is always triggered:</p> <pre><code>TSearchThread = class(TThread) private ... protected ... procedure DoTerminate; override; // &lt;-- add this public destructor Destroy; override; // &lt;-- add this end; </code></pre> <p></p> <pre><code>constructor TSearchThread.Create(Owner: TmFileScan; SubDir, Started: Boolean; FilePaths, Filter: TStrings; fOnFileFound: TOnFileFoundEvent; fOnReady: TOnReadyEvent); begin inherited Create(true); ... ffList := TStringList.Create; // &lt;-- add this ... Resume; end; // add this destructor TSearchThread.Destroy; begin ffList.Free; inherited Destroy; end; procedure TSearchThread.Execute; var ... begin // function FindFile // remove this { ffList:= TStringList.Create; try while not Terminated do begin } for q:= 0 to ffPaths.Count - 1 do begin if Terminated then Break; // &lt;-- add this for n:= 0 to ffFilters.Count - 1 do begin if Terminated then Break; // &lt;-- add this Spec:= ffFilters[n]; RFindFile(BackSlashFix(ffPaths[q])); end; end; // remove this { Synchronize(Ready); // &lt;-- remove this Terminate; end; finally ffList.Free; end; } end; // add this procedure TSearchThread.DoTerminate; begin Synchronize(Ready); inherited; end; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload