Exception raised on TOmniParallelJoin.Execute: Task can be only monitored with a single monitor
I need to send a message to the main thread so I tried to set the EventMonitor from TaskConfig:
var
TaskConfig: IOmniTaskConfig;
Join: IOmniParallelJoin;
begin
Join := TOmniParallelJoin.Create;
Join.Task(...);
TaskConfig := Parallel.TaskConfig;
TaskConfig.MonitorWith(FGui.OmniEventMonitor);
Join.NumTasks(NumTasks).TaskConfig(TaskConfig).Execute;
end;
But an exception is raised from TOmniTaskControl.SetMonitor(hWindow: THandle): IOmniTaskControl; with the message Task can be only monitored with a single monitor.
Maybe taskControl.Unobserved; should only be called after checking that no monitor is assigned ?
https://github.com/gabr42/OmniThreadLibrary/blob/721dc450c65b4befe855a2c255c76bf3b20e0154/OtlParallel.pas#L2009-L2011
What comes to my mind first: Can't you use the OnFinished handler? Otherwise check out the trick I did in my branch with DirectExecute in order to handle extra processing for arbitrary tasks: https://stackoverflow.com/questions/62327719/ I did a Pull request for this.