Eck. Try TAsyncProcess
Comment out some lines from ProcessExecute.
procedure ProcessExecute(const AProcess: TProcess; const ASynEdit: TSynEdit);
begin
with AProcess do
begin
Options := Options + [poUsePipes, poStderrToOutPut];
PipeBufferSize := 1024;
ShowWindow := swoHIDE;
Execute;
(* <<<<<< REMOVE THE OLD streaming code.
while Running do
begin
while Running and (Output.NumBytesAvailable = 0) do
begin
Sleep(400);
end;
SynEditWrite(ASynEdit, StreamReadChunk(Output));
end;
repeat
SynEditWrite(ASynEdit, StreamReadChunk(Output));
until Output.NumBytesAvailable = 0;
*) <<< END COMMENT
end;
end;
Add a OnReadData event to TAsyncProcess.
procedure TForm1.AsyncProcess1ReadData(Sender: TObject);
begin
repeat
SynEditWrite(SynEdit1, StreamReadChunk(AsyncProcess1.Output));
until AsyncProcess1.Output.NumBytesAvailable = 0;
end;
But, you still can only run one process at a time, so you need to make sure you check Running before calling Execute again:
if not AsyncProcess1.Running then
begin
AsyncProcess1.Executable := 'gcc';
AsyncProcess1.Parameters.Text := '--h';
ProcessExecute(AsyncProcess1, SynEdit1);
end;
Bad news is, I now cant get java running. Gcc, yes