gabr42 / gabr42/OmniThreadLibrary

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

Open
#154 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Pascal
Stars
513
Forks
147
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.