Consider the following short program that uses PPL:

Consider the following short program that uses PPL:
procedure TForm3.FormCreate(Sender: TObject);
var
  task: ITask;
begin
  task := TTask.Create(
    procedure
    begin
    end
  );
  task := task.Start;
  task := nil;
end;
If you put a breakpoint in TTask.Destroy, and run the program, FormCreate executes, the main form is shown, but the destructor is not called even trough "task" variable becomes nil and refcount should be 1.
When I close the main form, the destructor executes. Why?
Update: if I put a breakpoint before nil-ing the task variable and add a watch I see that refCount is 4???

Comments