thanks a lot man and for the rest of the lazarus community on patiently guiding me i managed to finished it now and its working good
Sorry man, but this code is a horror. ;-)
You should really try to understand threads first, before writing such code.
It seems like pure luck if this works. You still have things like...
procedure TMyThread.Execute;
repeat
if (scanned = false) and (i < frmMain.lstAdd.Items.Count) then
begin
sPro.CommandLine := 'HandbrakeCLI -i ' + '"' + frmMain.lstAdd.Items[i] + '"' + ' -t 0';
...in your code. You're still referencing frmMain unsynchronized in several places.
But you should completely rethink your design. It would be better to buffer all results in a Variable/Field of the Thread-Object and write the entire thread code first without ANY reference to frmMain.
Only in OnTerminate you should copy the result to the visual controls.
Once this works, you can add ONE Synchronize(@UpdateGui) or something to show that the thread is working.
But accessing the frmMain inside the thread should be the absolute exception, not the rule!
The way you do it now, you don't need a thread. ;-)
If everything is synchronized, it's almost the same as running the code in the main thread.
Please read more and try to understand. Threads are not just another class.