alr1976 0 Posted April 21, 2019 Hi , I Need to handle exception in parallel.foreach because i Need to check for each task i got problem. I tried: parallel.&Foreach(0,1) .TaskConfig(parallel.TaskConfig.OnTerminated( procedure(const task: IOmniTaskControl) var excp: Exception; begin if assigned(task.FatalException) then begin excp := task.DetachException; outvatinfo.Lines.Add('Caught async exception '+excp.ClassName+':'+excp.Message); FreeAndNil(excp); end; end)) .Execute( procedure(const value: integer) begin raise Exception.Create('Exception in Async'); //strtofloat('&'); // outvatinfo.Lines.Add(datetimetostr(now())) ; end); But It crash.... Someone can help me? Thanks Alessandro Share this post Link to post
Primož Gabrijelčič 223 Posted April 22, 2019 To quote "the book": Quote 3.12.9 Handling exceptions ForEach abstraction does not yet implement any exception handling. You should always wrap task method (code passed to the Execute) in try..except if you expect the code to raise exceptions. http://www.omnithreadlibrary.com/book/chap06.html#highlevel-foreach-exceptions Share this post Link to post
alr1976 0 Posted April 26, 2019 Hi! I Need to run a task each 1 second but i Need to pass a variable First Time. It Is possible? How ? Can you do male a small example? Thanks PS i buy your last book. Next week i Will riceive It. Share this post Link to post
Rudy Velthuis 91 Posted April 26, 2019 (edited) On 4/21/2019 at 10:29 PM, alr1976 said: parallel.&Foreach(0,1) Not an answer, but I'm just curious: why &Foreach? AFAIK, foreach is not a keyword. Edited April 26, 2019 by Rudy Velthuis Share this post Link to post