Jump to content
alr1976

Handle parallel.foreach exception

Recommended Posts

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

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
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 by Rudy Velthuis

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×