Recent

Author Topic: TProcess Thread handing HOW TO?  (Read 26642 times)

Leledumbo

  • Hero Member
  • *****
  • Posts: 8111
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: TProcess Thread handing HOW TO?
« Reply #15 on: February 01, 2014, 08:08:37 pm »
Quote
aaahh SO you do put the TProcess inside the thread and then the thread just handles it. (?)
Yes
Quote
just call Thread.Create(true) in a suspended state suspending the TProcess and when I need to use it just Thread execute then suspend it for the time limit I need then call resume to have it execute the TProcess again?
Suspend and Resume will suspend and resume the thread, respectively. But I don't think it will suspend the underlying process. I don't know, you have to confirm that yourself. As you can see, I didn't create suspended thread. The threads are executed immediately after creation.

userx-bw

  • Full Member
  • ***
  • Posts: 178
Re: TProcess Thread handing HOW TO?
« Reply #16 on: February 01, 2014, 08:47:35 pm »
Quote
aaahh SO you do put the TProcess inside the thread and then the thread just handles it. (?)
Yes
Quote
just call Thread.Create(true) in a suspended state suspending the TProcess and when I need to use it just Thread execute then suspend it for the time limit I need then call resume to have it execute the TProcess again?
Suspend and Resume will suspend and resume the thread, respectively. But I don't think it will suspend the underlying process. I don't know, you have to confirm that yourself. As you can see, I didn't create suspended thread. The threads are executed immediately after creation.


I'm working on it now, just trying to figure out your layout in your form it is different.

Quote
unit FormMain;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls,
  ComCtrls, ExtCtrls, Buttons, FileUtil, IniPropStorage, ColorProgress;

type

  { TMainForm }

  TMainForm = class(TForm)
 ......
 
    procedure BtnAboutClick(Sender: TObject);
       
   
  private
    { private declarations }
    function FileAlreadyInList(const FilePath: String): Boolean;
    function AddFile(const FilePath: String): Boolean;
    procedure AddDir(Directory: String; Recursive: Boolean);
    procedure CheckAll(Checked: Boolean);
    procedure EnableControls(Enable: Boolean);
    procedure CleanProgressAndResult;

   
   
    you have your function and procedure headers names here,
    I keep getting errors forward deleclrations
   
   
Quote

  public
    { public declarations }
  end;

  { TUPXThread }

  TUPXThread = class(TThread)
  private
    { Private declarations }
    FIndex: Integer;
    FDoneCount: PInteger;
    FThreadCount: PInteger;
    FForm: TMainForm;
    FUPXCmd: String;
    FUPXArgs: TStrings;
    FResultMsg: String;
    procedure UpdateStatus;
  public
    property ResultMsg: String read FResultMsg;
    constructor Create(const AIndex: Integer;
      ADoneCount, AThreadCount: PInteger; AForm: TMainForm;
      const AUPXCmd: String; const AUPXArgs: TStrings);
    destructor Destroy; override;
    procedure Execute; override;
  end;

  { TUPXThreadRunner }

  TUPXThreadRunner = class(TThread)
  private
    FForm: TMainForm;
    FUPXFile: String;
  public
    constructor Create(AForm: TMainForm; const AUPXFile: String);
    procedure Execute; override;
  end;

then you do this again
Quote

var
  MainForm: TMainForm;

implementation

why are you making the MainForm a Variable?

this is just checking for the Pascal version, so no big deal in my case?
Quote

{$if FPC_FULLVERSION >= 20400}
  {$R *.lfm}
{$endif}

Quote
uses
  FormAdv, FormAbout, AppOptions, Helpers, StrUtils, SyncObjs, Process;

how do you know what or wich units to put in the two seperate uses areas?

then Thread Variables? how do I know what they are or do I have to worry about that as I am just using one thread where you are multiThreading

and I am finding that writing functions and procedures and where do  I put them so that when I call them I don't get I have no Idea what your taking about from the compiler errors

Quote

threadvar
  ListItemCS: TCriticalSection;

{ TMainForm functions/procedures }

function TMainForm.FileAlreadyInList(const FilePath: String): Boolean;
var
  i: Integer;
  begin
......
end;


why is that TMainForm then function name ? then further down you call it with out the TMainForm.FileAlreadyInList(data);


Quote
  if not FileAlreadyInList(FilePath) then begin
  ....
 
 
 
 
 is all the Thread code suppuse to go on the bottom of the page?
 
Quote



{ TUPXThread }

procedure TUPXThread.Execute;
var
  TempPos: LongWord;
begin
  with TProcess.Create(nil) do
    try
      ...
      except
        on e: Exception do
          FResultMsg := e.Message;
      end;
      Synchronize(@UpdateStatus);
    finally
      Free;
    end;
end;

procedure TUPXThread.UpdateStatus;
begin
  ListItemCS.Acquire;
  try
   ....
  finally
    ListItemCS.Release;
  end;
end;

constructors

Quote
constructor TUPXThread.Create(const AIndex: Integer; ADoneCount,
  AThreadCount: PInteger; AForm: TMainForm; const AUPXCmd: String;
  const AUPXArgs: TStrings);
begin
  FreeOnTerminate := True;
  FIndex := AIndex;
  FDoneCount := ADoneCount;
  FThreadCount := AThreadCount;
  FForm := AForm;
  FUPXCmd := AUPXCmd;
  FUPXArgs := AUPXArgs;
  Inc(FThreadCount^);
  inherited Create(False);
end;

that is just property setting I need, right. (perhaps a redundent question)

Quote

destructor TUPXThread.Destroy;
begin
  Dec(FThreadCount^);
end;

{ TUPXThreadRunner }

constructor TUPXThreadRunner.Create(AForm: TMainForm; const AUPXFile: String);



there you put the main form in the constructor, why is that needed.

Quote

initialization
{$if FPC_FULLVERSION < 20400}
  {$I FormMain.lrs}
{$endif}
  ListItemCS := TCriticalSection.Create;

finalization
  ListItemCS.Free;

end.

why is the initialization at the bottom?

I hope that is not too many questions for you.

thanks
My Finished Projects
https://sourceforge.net/projects/mhsetroot/
https://sourceforge.net/projects/gmhsetrootfreepascalfrontend/

HP Elitetbook 6930p Dual Core Intel vPro 2.66 gHz
VOID (Linux) 64bit

userx-bw

  • Full Member
  • ***
  • Posts: 178
Re: TProcess Thread handing HOW TO?
« Reply #17 on: February 01, 2014, 10:57:27 pm »
I rewrote starting all over with just the thread.
Code: [Select]
unit FormMain;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, process, FileUtil, Forms, Controls, Graphics, Dialogs,
  StdCtrls, LCLType, LCLIntf, ExtDlgs, Buttons, LCLProc, LazHelpHTML;


type
  TShowStatusEvent = procedure(Status: String) of Object;
  { TForm1 }

  TForm1 = class( TForm)
    Button1: TButton;
    Label1: TLabel;
    Process: TProcess;
    setImgDir_bn: TButton;
    procedure Button1Click( Sender: TObject) ;
    procedure setImgDir_bnClick( Sender: TObject) ;
  private
    { private declarations }
  public
    { public declarations }
  end;

  {CycleThread}

   CycleScreenThread = class(TThread)
    private
      FResultMsg: String;
      fStatusText : string;
      FOnShowStatus: TShowStatusEvent;
      procedure ShowStatus;
    protected
      procedure Execute; override;
    public
      Constructor Create(CreateSuspended : boolean);
      property ResultMsg: String read FResultMsg;
      property OnShowStatus: TShowStatusEvent read FOnShowStatus write FOnShowStatus;
    end;



var
  Form1: TForm1;
  chosenDir:string;
  FindImageFiles:TStringList;


implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.setImgDir_bnClick( Sender: TObject) ;
begin
    SelectDirectory(chosenDir,[sdPrompt],0);
    SetCurrentDir(ChosenDir);
    FindImageFiles := FindAllFiles(chosenDir, '*.*', false);
    FindImageFiles.Sort;
    Form1.Caption:=ChosenDir;
    Label1.Caption:=IntToStr(FindImageFiles.Count);
end;

procedure TForm1.Button1Click( Sender: TObject) ;
begin
               // CycleScreenThread.Start;
end;




constructor CycleScreenThread.Create(CreateSuspended : boolean);
 begin
   FreeOnTerminate := True;
   inherited Create(CreateSuspended);
 end;

 procedure CycleScreenThread.ShowStatus;
 // this method is executed by the mainthread and can therefore access all GUI elements.
 begin
   if Assigned(FOnShowStatus) then
   begin
     FOnShowStatus(fStatusText);
   end;
 end;

 procedure CycleScreenThread.Execute;
 var
 i:integer;
 begin
  with Tprocess.Create(nil) do
  try
    try
     i := 0;
       while i < FindImageFiles.Count do
      begin
        if (CompareFileExt(FindImageFiles.Strings[i], 'jpg') = 0 ) or
           (CompareFileExt(FindImageFiles.Strings[i], 'png') = 0 )
            then
             begin
                Executable:= 'mhsetroot';

                Parameters.Add('-center');
                Parameters.Add(FindImageFiles.Strings[i]);

               {  Commented out for testing }
               {
               if SetColorsRG.ItemIndex > -1 then
               begin
                case SetColorsRG.ItemIndex of
                 0:
                 begin
                      Parameters.Add('-solid');
                      Parameters.Add(addC1);
                 end;
                 1:
                 begin
                      Parameters.Add('-add');
                      Parameters.Add(addC1);
                      Parameters.Add('-add');
                      Parameters.Add(addC2);
                      Parameters.Add('-gradient');
                      Parameters.Add(intTostr(grad1));
                 end;
                 2:
                 begin
                      Parameters.Add('-add');
                      Parameters.Add(addC1);
                      Parameters.Add('-add');
                      Parameters.Add(addC2);
                      Parameters.Add('-gradient');
                      Parameters.Add(intTostr(grad1));
                      // add second gradient
                      Parameters.Add('-add');
                      Parameters.Add(addC3);
                      Parameters.Add('-add');
                      Parameters.Add(addC4);
                      Parameters.Add('-gradient');
                      Parameters.Add(intToStr(grad1));
                 end;
                 3:
                 begin
                      Parameters.Add('-addd');
                      Parameters.Add(addC1);
                      Parameters.Add(intToStr(alpha1));
                      Parameters.Add('-addd');
                      Parameters.Add(addC2);
                      Parameters.Add(intTostr(alpha2));
                      Parameters.Add('-gradient');
                      Parameters.Add(intToStr(grad1));
                 end;
                 4:
                 begin
                      Parameters.Add('-addd');
                      Parameters.Add(addC1);
                      Parameters.Add(intToStr(alpha1));
                      Parameters.Add('-addd');
                      Parameters.Add(addC2);
                      Parameters.Add(intToStr(alpha2));
                      Parameters.Add('-gradient');
                      Parameters.Add(intTostr(grad1));
                      //add second gradinet
                      Parameters.Add('-addd');
                      Parameters.Add(addC3);
                      Parameters.Add(intTostr(alpha1));
                      Parameters.Add('-addd');
                      Parameters.Add(addC4);
                      Parameters.Add(intToStr(alpha2));
                      Parameters.Add('-gradient');
                      Parameters.Add(intToStr(grad1));
                 end;
           end; //end case
        end;

    if tint_cb.Checked then
    begin
       Parameters.Add('-tint');
       Parameters.Add(addTint);
     end;
    if blur_cb.Checked then
    begin
       Parameters.Add('-blur');
       Parameters.Add(intTostr(blur));
    end;

    if sharp_cb.Checked then
    begin
       Parameters.Add('-sharpen');
       Parameters.Add(intTostr(sharpen));
    end;

    if contrast_cb.Checked then
    begin
       Parameters.Add('-contrast');
       Parameters.Add(intTostr(contrast));
    end;

    if bright_cb.Checked then
    begin
       Parameters.Add('-brightness');
       Parameters.Add(intToStr(brightness));
    end;

    if gamma_cb.Checked then
    begin
       Parameters.Add('-gamma');
       Parameters.Add(intToStr(gamma));
    end;

    if alpha_cb.Checked then
    begin
       Parameters.Add('-alpha');
       Parameters.Add(intToStr(alpha3));
    end;

    if FlipBgRG.ItemIndex > -1 then
    case FlipbgRg.ItemIndex of
     0: Parameters.Add('-flipv');
     1: Parameters.Add('-fliph');
     2: Parameters.Add('-flipd');
    end;

    if orgSRG.ItemIndex > -1 then
    case orgSRG.ItemIndex of
         0:
         begin
              Parameters.Add('-fs');
              Parameters.Add(FindImageFiles.Strings[i]);
         end;
         1:
         begin
              Parameters.Add('-center');
              Parameters.Add(FindImageFiles.Strings[i]);
         end;
         2:
         begin
              Parameters.Add('-fill');
              Parameters.Add(FindImageFiles.Strings[i]);
         end;
         3:
         begin
              Parameters.Add('-fimgd');
              Parameters.Add(FindImageFiles.Strings[i]);
         end;
         4:
         begin
              Parameters.Add('-fimgh');
              Parameters.Add(FindImageFiles.Strings[i]);
         end;
         5:
         begin
              Parameters.Add('-fimgv');
              Parameters.Add(FindImageFiles.Strings[i]);
         end;
         6:
         begin
              Parameters.Add('-tile');
              Parameters.Add(FindImageFiles.Strings[i]);
         end;
         7:
         begin
              Parameters.Add('-tilev');
              Parameters.Add(FindImageFiles.Strings[i]);
         end;
         8:
         begin
              Parameters.Add('-tileh');
              Parameters.Add(FindImageFiles.Strings[i]);
         end;
         9:
         begin
              Parameters.Add('-tilehv');
              Parameters.Add(FindImageFiles.Strings[i]);
         end;
    end;

    if UserSRG.ItemIndex > -1 then
    case userSRG.ItemIndex of
         0:
         begin
              Parameters.Add('-dcenter');
              Parameters.Add(imgWidth);
              Parameters.Add(FindImageFiles.Strings[i]);
         end;
         1:
         begin
              Parameters.Add('-dfimgh');
              Parameters.Add(imgWidth);
              Parameters.Add(FindImageFiles.Strings[i]);
         end;
         2:
         begin
              Parameters.Add('-dfimgv');
              Parameters.Add(imgWidth);
              Parameters.Add(FindImageFiles.Strings[i]);
         end;
         3:
         begin
              Parameters.Add('-dfimgd');
              Parameters.Add(imgWidth);
              Parameters.Add(FindImageFiles.Strings[i]);
         end;
         4:
         begin
              Parameters.Add('-dtile');
              Parameters.Add(imgWIdth);
              Parameters.Add(FindImageFiles.Strings[i]);
         end;
         5:
         begin
              Parameters.Add('-dtileh');
              Parameters.Add(imgWidth);
              Parameters.Add(FindImageFiles.Strings[i]);
         end;
         6:
         begin
              Parameters.Add('-dtilev');
              Parameters.Add(imgWidth);
              Parameters.Add(FindImageFiles.Strings[i]);
         end;
         7:
         begin
              Parameters.Add('-dtilehv');
              Parameters.Add(imgWidth);
              Parameters.Add(FindImageFiles.Strings[i]);
         end;
    end;
       }
       {end of comment out code for now }


       // BProcess.Options := BProcess.Options + [poWaitOnExit, poUsePipes];
        Execute;
        CycleScreenThread.Start;
         if ExitStatus <> 0 then begin
          with TStringList.Create do
            try
              LoadFromStream(StdErr);
              FResultMsg := Text;
            finally
              Free;
            end;
          end;
        Free;
        Application.ProcessMessages;
        sleep(3000);
        end; //end compaire file types
        i := i + 1;
        if i = FindImageFiles.Count then i := 0; // keep cycling through images
     end; // end while loop

    except
        on e: Exception do
          FResultMsg := e.Message;
      end;  // end second try

      finally
      Free;
      FindImageFiles.Free;
   end; //end first try

end;


end.

and I get this error trying to start the thread

Code: [Select]
formmain.pas(339,32) Error: Only class class methods, class properties and class variables can be accessed in class methods
My Finished Projects
https://sourceforge.net/projects/mhsetroot/
https://sourceforge.net/projects/gmhsetrootfreepascalfrontend/

HP Elitetbook 6930p Dual Core Intel vPro 2.66 gHz
VOID (Linux) 64bit

taazz

  • Hero Member
  • *****
  • Posts: 5363
Re: TProcess Thread handing HOW TO?
« Reply #18 on: February 01, 2014, 11:05:15 pm »
And rightly so, CycleScreenThread is a class not an object. You have to create an object from it ee call CycleScreenThread.create somewhere in your code and save the reference to that object to a variable so that you can later on access the object to call start or free or hat ever needs to be called.

That is one of the reasons why it is customary to declare all our classes starting with the latter T so we know it is a type and not a variable you can call out of the blue.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

userx-bw

  • Full Member
  • ***
  • Posts: 178
Re: TProcess Thread handing HOW TO?
« Reply #19 on: February 01, 2014, 11:33:43 pm »
And rightly so, CycleScreenThread is a class not an object. You have to create an object from it ee call CycleScreenThread.create somewhere in your code and save the reference to that object to a variable so that you can later on access the object to call start or free or hat ever needs to be called.

That is one of the reasons why it is customary to declare all our classes starting with the latter T so we know it is a type and not a variable you can call out of the blue.
thanks

but lazarus example.
Code: [Select]

  constructor TMyThread.Create(CreateSuspended : boolean);
  begin
    FreeOnTerminate := True;
    inherited Create(CreateSuspended);
  end;

......
 var
    MyThread : TMyThread;
  begin
    MyThread := TMyThread.Create(True); // This way it doesn't start automatically
    ...
    [Here the code initialises anything required before the threads starts executing]
    ...
    MyThread.Start;
  end;

my code
Code: [Select]

var
  Form1: TForm1;
  chosenDir:string;
  FindImageFiles:TStringList;
  CycleScreenThread:TCycleScreenThread;     

.......

procedure TForm1.Button1Click( Sender: TObject) ;
begin

     CycleScreenThread = TCycleScreenThread.Create(true);
     CycleScreenThread.Start;
end;

.......

constructor CycleScreenThread.Create(CreateSuspended : boolean);
 begin
   FreeOnTerminate := True;
   inherited Create(CreateSuspended);
 end;         

my errors from my code
Code: [Select]

formmain.pas(73,57) Error: Illegal expression
formmain.pas(80,37) Error: class identifier expected
formmain.pas(82,20) Error: Identifier not found "FreeOnTerminate"
formmain.pas(83,14) Error: Methods can be only in other methods called direct with type identifier of the class
formmain.pas(83,14) Fatal: Syntax error, ";" expected but "identifier CREATE" found

it says that Create(true) is Illegal expression
My Finished Projects
https://sourceforge.net/projects/mhsetroot/
https://sourceforge.net/projects/gmhsetrootfreepascalfrontend/

HP Elitetbook 6930p Dual Core Intel vPro 2.66 gHz
VOID (Linux) 64bit

taazz

  • Hero Member
  • *****
  • Posts: 5363
Re: TProcess Thread handing HOW TO?
« Reply #20 on: February 01, 2014, 11:56:24 pm »
you did not declare anywhere the  TCycleScreenThread instead you declared
Code: [Select]
CycleScreenThread = class(TThread)
..........
end;

So clean up your code I guess.

Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

userx-bw

  • Full Member
  • ***
  • Posts: 178
Re: TProcess Thread handing HOW TO?
« Reply #21 on: February 02, 2014, 12:04:40 am »
you did not declare anywhere the  TCycleScreenThread instead you declared
Code: [Select]
CycleScreenThread = class(TThread)
..........
end;

So clean up your code I guess.

as in

Code: [Select]
var
CycleScreenThread:TCycleScreenThread;
?
because if that is a yes then it is up where I put my code last line on the var part making it global.
other then that I have no idea what you mean.
My Finished Projects
https://sourceforge.net/projects/mhsetroot/
https://sourceforge.net/projects/gmhsetrootfreepascalfrontend/

HP Elitetbook 6930p Dual Core Intel vPro 2.66 gHz
VOID (Linux) 64bit

userx-bw

  • Full Member
  • ***
  • Posts: 178
Re: TProcess Thread handing HOW TO?
« Reply #22 on: February 02, 2014, 12:25:26 am »
you did not declare anywhere the  TCycleScreenThread instead you declared
Code: [Select]
CycleScreenThread = class(TThread)
..........
end;

So clean up your code I guess.

found the error I made had = and not :=
Code: [Select]
CycleScreenThread = class(TThread)
but now  it is blowing up
screen shot attached...
something about having more then one maybe
as in the debugger I stop it on the create call then it goes to the constructor and through it twice then I get this error , but I only call create once.

corrected:
actually it when  i click step into it jumps from the constructor line straight to the end, then it goes back to the constructor then into the call then it blows up.

« Last Edit: February 02, 2014, 12:32:35 am by userx-bw »
My Finished Projects
https://sourceforge.net/projects/mhsetroot/
https://sourceforge.net/projects/gmhsetrootfreepascalfrontend/

HP Elitetbook 6930p Dual Core Intel vPro 2.66 gHz
VOID (Linux) 64bit

taazz

  • Hero Member
  • *****
  • Posts: 5363
Re: TProcess Thread handing HOW TO?
« Reply #23 on: February 02, 2014, 01:11:42 am »
I think that's a linux problem you need to add the cthreads unit in the projects uses clause for this to work.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

userx-bw

  • Full Member
  • ***
  • Posts: 178
Re: TProcess Thread handing HOW TO?
« Reply #24 on: February 02, 2014, 01:13:38 am »
well I got the thread error fixed now it does not like the loop

Code: [Select]
   while i < FindImageFiles.Count do
      begin                                             
it goes to the first part of this loop and its like it just skips over everything in between and straight down to this like where it give me an error message.

Code: [Select]
    if i = FindImageFiles.Count then i := 0; // keep cycling through images               

why would it skip what it is suppose to look at within the loop?
My Finished Projects
https://sourceforge.net/projects/mhsetroot/
https://sourceforge.net/projects/gmhsetrootfreepascalfrontend/

HP Elitetbook 6930p Dual Core Intel vPro 2.66 gHz
VOID (Linux) 64bit

userx-bw

  • Full Member
  • ***
  • Posts: 178
Re: TProcess Thread handing HOW TO?
« Reply #25 on: February 02, 2014, 01:16:08 am »
I think that's a linux problem you need to add the cthreads unit in the projects uses clause for this to work.
yep it was in there but like this
Code: [Select]
program gmhsetrootThread;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  cthreads, Interfaces, // this includes the LCL widgetset
  Forms, FormMain;     

so I just added it outside the IFDEF now I got another problem i was writing about when you posted your response.
My Finished Projects
https://sourceforge.net/projects/mhsetroot/
https://sourceforge.net/projects/gmhsetrootfreepascalfrontend/

HP Elitetbook 6930p Dual Core Intel vPro 2.66 gHz
VOID (Linux) 64bit

userx-bw

  • Full Member
  • ***
  • Posts: 178
Re: TProcess Thread handing HOW TO?
« Reply #26 on: February 02, 2014, 01:21:13 am »
when you have two trys how is it suppose to go?

Code: [Select]
   try
        try

         finally
          end;
except
 end;
or
Code: [Select]
try
      try
       except
        end;
 finally
 end;
My Finished Projects
https://sourceforge.net/projects/mhsetroot/
https://sourceforge.net/projects/gmhsetrootfreepascalfrontend/

HP Elitetbook 6930p Dual Core Intel vPro 2.66 gHz
VOID (Linux) 64bit

taazz

  • Hero Member
  • *****
  • Posts: 5363
Re: TProcess Thread handing HOW TO?
« Reply #27 on: February 02, 2014, 01:37:23 am »
both are accepted constructs what you need to do?
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

userx-bw

  • Full Member
  • ***
  • Posts: 178
Re: TProcess Thread handing HOW TO?
« Reply #28 on: February 02, 2014, 01:44:16 am »
@Leledumbo
@taazz

now that I got a thread started it seems that it does not like my loop what is using an integer, because it just skips over what is in side of the loop creating the TProcess and executing it.

what I have going on here is a two part process.

part one, an array of image files that need to go through a loop to pick one out at a time then send to the TProcess then put into a wait state until said time elapses.

the second part is the TProcess that executes the Linux external program.

when the image  array is at the last element it has to be reset to the first element, so it can keep displaying images on the desktop.

It has to run the entire time until the user tells the program to stop changing the images on the desktop.

if I  remove the image loop then put it into a function then run it on a timer using sleep then send it to the thread so it can go into the TProcess to be executed that then now requires two threads and that sync thing has to be done and all that ????????

I am not sure of how to say it better.
My Finished Projects
https://sourceforge.net/projects/mhsetroot/
https://sourceforge.net/projects/gmhsetrootfreepascalfrontend/

HP Elitetbook 6930p Dual Core Intel vPro 2.66 gHz
VOID (Linux) 64bit

userx-bw

  • Full Member
  • ***
  • Posts: 178
Re: TProcess Thread handing HOW TO?
« Reply #29 on: February 02, 2014, 01:48:24 am »
both are accepted constructs what you need to do?

I just copied a bit of someones code that they had me look at so I'd get the idea on how to run a thread and they had two tries in it so I just put them in there and at the bottom of my code it wants both the finally to free up what ever needs to be freed  and the except (on error) and I just want to be sure I had them in the right order is all. and now I got more problems if you could take a look at me last post in here.

thanks for you help btw
My Finished Projects
https://sourceforge.net/projects/mhsetroot/
https://sourceforge.net/projects/gmhsetrootfreepascalfrontend/

HP Elitetbook 6930p Dual Core Intel vPro 2.66 gHz
VOID (Linux) 64bit