Home › Forum › Omnis General Forum › Worker objects
-
Worker objects
Posted by Obonye on November 13, 2024 at 5:29 pmHi @everyone,
Is it possible to create multiple worker objects in a single class? If yes, how to I call the method $complete for each of the worker? This is what I want to do: to use smtpclientworker and timerworker in a remote form jsSMTPSend.
Martin.
haley replied 6 months, 3 weeks ago 3 Members · 5 Replies -
5 Replies
-
Martin,
Just inherit an object class from the worker you want to work with. You would need to create an object class and then go to the $superclass property and choose the right worker object. Each class has now its own $completed method that you can override.
However the question would be why you would like to use a timer worker for a remote form? Since the worker run on server only it might be better to use a timer component on the form rather an object class – depending on what you want to do.
There is also a challenge when you run a worker on the server to get the information back to the client. You would need to push the data to the client if the worker runs asynchronously. If the worker does not run asynchronously then you can use $cinst.$container().$myMethod to access a method of the container (the remote form) that runs the worker object (assuming the worker object is an instance variable).
I hope this makes sense.
Best,
Andreas
-
I have created 2 instance variables for the timer and the smtp worker and assigned the superclass for each object. I have created the method $complete in the remote form. How will each of the object call it’s $complete method which performs different function?
-
Reason of using timer, I’m using the timer in the loading overlay timer in a long process like sending many customer statements as email attachment.
-
Hi Martin,
I would use the timer component rather the timer object. The timer control could then check an instance variable that is set pushed from the other object to the client.
If the other object runs asynchronously then it would need to push the result and the instance variable. I’d rather recommend to run the other object synchronously as it does not require a push thought.
Best,
Andreas
-
-
@Fall Guys Yes, you can create multiple worker objects in a single class. To call the complete method for each worker, you can instantiate the workers in the class and then iterate through them, invoking the complete method for each one.
Log in to reply.