Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception raised on TOmniParallelJoin.Execute: Task can be only monitored with a single monitor #154

Open
yann-papouin opened this issue Oct 28, 2020 · 1 comment

Comments

@yann-papouin
Copy link

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 ?

Parallel.ApplyConfig(FTaskConfig, taskControl);
taskControl.Unobserved;
(FJoinStates[iProc] as IOmniJoinStateEx).TaskControl := taskControl;

@HHasenack
Copy link

HHasenack commented Oct 28, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants