How to Stop all Pipeline tasks correctly

非 Y 不嫁゛ 提交于 2019-12-01 01:38:38

In your case of over-simplified one-stage pipeline suffice would be moving check into the worker stage itself.

procedure Retriever(const input: TOmniValue; var output: TOmniValue);
var 
  ....
begin
   if FStopAll then exit;
   X   := Input.AsString;
....

PS. I want to repeat that your code leaks memory badly, and that you ignored all my notes I stated before.

PPS. This code not also makes little sense (there is not point in flip-vloppign the variable to one value then to another) but is syntactically incorrect and would not compile. Thus it is not the same code you actually run. It is some different code.

procedure TForm1.AbortButton(Sender: TObject);
 begin
   try
     FStopAll := False;
   finally
     FStopAll := True;
   end;
 end;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!