How to cause Value Listeners to be serviced immediately?


#1

I have a system that loads a configuration file, then immediately performs some actions based on values that get updated by the configuration file load.

The problem is, that the listeners to these values don’t get called till the event loop runs.

I’ve kludged a solution to load the config file, then set a timer to act on it, but this seems kludgy and might break under an unusual situation.

Is there a way to programmatically cause the value listeners to be serviced right away?

Edit: I found the MessageManager::getInstance()->runDispatchLoopUntil (50); statement. This seems to work, but is there a way to know all the messages have been delivered?


#2

There’s not really an easy and safe way to service your listeners before the event loop runs - calling the runDispatchLoopUntil() method yourself is probably not a good idea. However, you could call your listener function directly as soon as the config file is loaded or perhaps create a wrapper class around a Value object that does this.

Ed


#3

Here’s an idea. Send a message to a configFileProcessed value once the config file is loaded. That way all the messages generated by processing the config file will have been serviced by the time the listener to configFileProcessed gets invoked.