OmniThread and exceptions…
Example # 48 is good… from demos of omni lib…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
procedure TOmniTasks.Test2; begin Parallel.Async( procedure begin Sleep(1000); raise Exception.Create('Exception in Async'); end, Parallel.TaskConfig.OnTerminated( procedure(const task: IOmniTaskControl) var e: Exception; begin if assigned(task.FatalException) then begin e := task.DetachException; FLogger.LogStr('foreCastSalesCount ' + e.Message, tlpError); // Log('Caught async exception %s:%s', [excp.ClassName, excp.Message]); FreeAndNil(e); end; end)); end; |