RaelB 4 Posted July 9, 2020 In the SimplePipeline project (from HL-III presentation), if I add a call to sleep in AddOne stage, the program (i.e. UI) blocks for 5 seconds. procedure AddOne(const input, output: IOmniBlockingCollection); var v: TOmniValue; begin for v in input do begin output.Add(v.AsInteger + 1); Sleep(1000); end; end; I would expect this to not block the UI, since it is running in a Thread/Task? Share this post Link to post
Primož Gabrijelčič 223 Posted July 9, 2020 SimplePipeline is, well, simple. This is the TButton event handler: procedure TfrmSimplePipeline.btnPipelineClick(Sender: TObject); var pipeline: IOmniPipeline; i: Integer; v: TOmniValue; begin pipeline := Parallel.Pipeline; pipeline.Stage(AddOne); pipeline.Stage(Invert); pipeline.Run; for i := 1 to 5 do pipeline.Input.Add(i); pipeline.Input.CompleteAdding; for v in pipeline.Output do lbLog.Items.Add(Format('%.3f', [v.AsDouble])); pipeline := nil; end; As you can see, the code starts the pipeline and then runs the loop that processes the results. This loop is run in a main thread and therefore blocks the UI. If you slow down the pipeline, it needs more time to generate the results and UI is blocked. Share this post Link to post