Thread pool stops working when a task is created while threads are being destroyed
There is this strange error i am encountering where omnithread stops scheduling tasks and just stops working...
Here is the code to reproduce the error i am having
Procedure PerformOperations(const task: IOmniTask); Begin Sleep(1000); End;
procedure TForm1.Button1Click(Sender: TObject); Var I: Integer; begin for I := 0 to 200 do CreateTask(PerformOperations). UnObserved.Schedule(ThreadPool); end;
procedure TForm1.FormCreate(Sender: TObject); begin ThreadPool := CreateThreadPool('ThreadPool'); ThreadPool.MaxExecuting := 60; ThreadPool.MaxQueued := 0; end;
When i click on the button it creates 200 tasks fine, but while looking at the thread count from task manager, as soon as the threads starts decreasing if i click on button1 that moment then thread count suddenly drops to 0 and after that no matter how many times i click on button1 for scheduling tasks no thread is created and no function is performed.
Hmmmm, this looks bad. It definitely shouldn't behave in this way. I'll look into it.
thanks. i am looking forward to the fix
@JunaidNoor1 In which version of the Omni thread library you are facing this issue? What is the Delphi version you are using?