I need help with AdxRtHistory.
I request data via VBA but does not wait for data to be retrieved.
While (.DataStatus = RT_DS_NULL_EMPTY Or .DataStatus = RT_DS_PARTIAL) And .RunStatus = RT_RS_BUSY
Could you please help me make vba wait until it gets an answer from Reuters ?
Thanks a lot,
VBA is single threaded. While your loop is running, it occupies the thread disallowing AdxRtHistory object to retrieve and process the data. AdfinX Real-Time API is asynchronous by design. Rather than trying to trick it into producing synchronous behavior, I would strongly advise that you follow the asynchronous pattern and split your code into the procedure that requests the data and immediately exits, and OnUpdate event callback, which will be raised once the object finished retrieving the data. See the tutorial following the link below for further details and an example.
If however you must opt for synchronous data retrieval, then you need to make sure to include in the body of your loop the DoEvents statement to cede the execution thread and allow messages from Windows message queue to be processed. I would also strongly advise to implement a timeout to prevent an endless loop. Attached is a quick and dirty example. In production you will want to include a lot more error handling, as the synchronous retrieval pattern makes the example more error prone. I cannot help but wonder if the addition of timeout implementation based on an arbitrary timeout interval and extra error handling are worth whatever it is that you're trying to achieve by implementing synchronous retrieval.