How to execute a program on PostBuild event in parallel?

I managed to set the compiler to execute another program when the project is built/ran with the following directive in project options:

call program.exe param1 param2

The problem is that the compiler executes "program.exe" and waits for it to terminate and THEN the project executable is ran.

What I ask: How to set the compiler to run both executables in parallel without waiting for the one in PostBuild event to terminate?

Thanks in advance

Answers


I'd have no clue how the IDE manages to wait for the termination of processes initiated by "start", but calling "CreateProcess" at its simplest in your own program starter seems to serve.

Compile sth. like;

program starter;

{$APPTYPE CONSOLE}

uses
  sysutils, windows;

var
  i: Integer;
  CmdLine: string;
  StartInfo: TStartupInfo;
  ProcInfo: TProcessInformation;
begin
  try
    if ParamCount > 0 then begin
      CmdLine := '';
      for i := 1 to ParamCount do
        CmdLine := CmdLine + ParamStr(i) + ' ';
      ZeroMemory(@StartInfo, SizeOf(StartInfo));
      StartInfo.cb := SizeOf(StartInfo);
      ZeroMemory(@ProcInfo, SizeOf(ProcInfo));
      if not CreateProcess(nil, PChar(CmdLine), nil, nil, False,
                      NORMAL_PRIORITY_CLASS, nil, nil, StartInfo, ProcInfo) then
        raise Exception.Create(Format('Failed to run: %s'#13#10'Error: %s'#13#10,
                            [CmdLine, SysErrorMessage(GetLastError)]));
    end;
  except
    on E:Exception do begin
      Writeln(E.ClassName + ', ' +  E.Message);
      Writeln('... [Enter] to dismiss ...');
      Readln(Input);
    end;
  end;
end.

and then on PostBuild put:

"X:\...\starter.exe" "X:\...\program.exe" param1 param2

Instead of call program.exe, use start program.exe


Create a bat file. Put there few commands with start, as Alan suggested:

start program.exe param1 param2
start program.exe param1 param2
start program.exe param1 param2 
start program.exe param1 param2

Then call this bat file.


Need Your Help

Generate colors between red and green for a power meter?

language-agnostic graphics colors interpolation

I'm writing a Java game and I want to implement a power meter for how hard you are going to shoot something.

Can Oxyplot be used in a Unit Test Library (C#)

c# graph plot scientific-computing oxyplot

I am creating a C# library without a User Interface, and as part of a unit test library, I would like to save these images of the graphs from the data produced in the Unit Tests.