Primož,
Thanks!
1) Actually, you can't, but there's not a good reason for this behaviour. I could add access to task parameter from the task controller side easily.
That would be fantastic!
This way we could easily access my Object (set using SetParameter) or even a class that inherits TOmniWorker (using CreateTask(TMyOmniWorker.Create(myObject))) from the, for example, OnTerminate method.
Btw, when using "CreateTask(TMyOmniWorker.Create()))..." how do I get the IOmniWorker to use the .Implementor and be able to access the instance of TMyOmniWorker created inside CreateTask(), for example in the OnMessage method?
2) This is safe only if you keep all normal data access rules for multithreading in mind. (I.e. don't access this object in the worker thread after you have send it to the owner.)
Does that mean: do not touch my Object (myInt) after "task.Comm.Send(MSG_OBJECT, myInt)" inside the "procedure(const task: IOmniTask)" ?
3a) For unobserved, read OmniThreadLibrary patterns – Task controller needs an owner.
Since I'm using .Schedule and GlobalOmniThreadPool, which is monitored, there's no need for Unobserved in my code?
If the above is correct, are problems to be expected if I do not use TOmniEventMonitor, that is: using .Schedule(myPoll) and myPool := CreateThreadPool() without specifying the Monitor?
I'm asking all this as I've noted lots of memory leaks (ReportMemoryLeaksOnShutdown) with my code (first post in this topic) when "tasksNumber" is rather large (even when using monitored GlobalOmniThreadPool).
Everything works ok if tasksNumber is < 50 or so. When it is > 50 (might be 80), upon closing the application there are lots of OTL related object leaks

p.s.
I know there's a memory leak in my sample code if GlobalOmniThreadPool.CancelAll is called before pool is empty (OnMessage not called therefore myInt not fred) - but if you try the code and set tasksNumber to 100, let it run/finish, after closing the application, there are memory leaks.
-žarko