IOmniWorker: Where goes the function to execute within the Task?
I am creating an OmniWorker-Task to do some data processing.
So far, the Task is able to receive and send messages from/to other tasks.Now I need to implement the main function for this task. This function will run continuously and do the data processing, while messages will modify it's behavio开发者_JS百科r.
But where do I put this main function?
Is there anything like an "Execute"-method for an OmniWorker, that I need to implement?Actually, TOmniWorker does not really support 'monolythic execution block + messaging' idiom. The whole idea behind TOmniWorker is that most of the code is executed in message handlers (and in the code called from them, of course) - as it is in the typical single-threaded Delphi application.
You can just send a special message ('Start!') and start your execution in the message handler but keep in mind that messages will not be processed while your message handler is executing. [To be more specific - you can send them but if you want to receive them you'll have to do it manually via Task.Comm.Receive.] This is not really unexpected as each TOmniWorker is a single-threaded environment and while it executes message handler it cannot do anything else.
精彩评论