multithreading - On MainForm closure OTL threads do not close -


closing mainform when otl treads still working iomnicancellationtoken not terminate threads. using following taskconfiguration code

private canceltoken: iomnicancellationtoken;

  canceltoken := createomnicancellationtoken;    fworker := parallel.foreach(0, calclist.count-1)     .taskconfig(parallel.taskconfig.onmessage(self))     .taskconfig(parallel.taskconfig.cancelwith(canceltoken))     .numtasks(nmax)       .nowait     .onstop(procedure (const task: iomnitask)      begin        task.invoke(procedure begin          fworker := nil;         end);       end);    fworker     .execute(       procedure (const value: integer)       begin          calcunit.entrysearch(value);       end); 

form.close canceltoken.signal ; makes form closes , threads go 'parallel.foreach worker' 'idle thread worker' threads not terminate. , program hangs. why threads not terminate? do wrong?

do check canceltoken issignalled in code? tasks not forced terminate automatically. instead have check cancellation in code , exit task when signaled.


Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -