Author |
Topic: ISubscriptionListPtr Count & GetByIndex (3 messages, Page 1 of 1) |
||||
---|---|---|---|---|---|
Moderators: VPfau | |||||
jlanawalt Posts: 88 Joined: Feb 12, 2009 |
Hi,
We have a function that tries to see if a symbols subscribed doing the following:
We have noticed that if this code is called before the subscription list is stable, GetByIndex will raise an exception and return null. Why would we not be able to GetByIndex for an index within the range of Count? Would we have better luck iterating the list in another manner? Is there some "subscription list complete" message we've been overlooking that we could pend these lookups on? We often run into issues with subscriptions after connecting or reconnecting so something about how we handle it seems to not be in sync with the way it was designed to be handled. We would appreciate some insight to help us make this more robust. Thank you, Jacob |
||||
VictorV Posts: 746 Joined: May 08, 2007 |
Hello,
your code snippet is perfect for iterating. The list can be considered as a stable one, if all operations are performed in context of the thread that created OECAPI instance. We tried to reproduce this issue without success. Could you please provide more details how to reproduce it? Victor Vins Lead Software Developer |
||||
jlanawalt Posts: 88 Joined: Feb 12, 2009 |
I apologize for not replying earlier to this. We do touch the API from two other threads when we load a chart to look at properties on a contract, like market hours, or to start a history request so I couldn't say that wasn't the reason for the error.
I ran across this again, and this time I went to lengths to disable or temporarily rework those calls so they are all within the thread that creates the API instance (the main windows thread) and still I had the problem. It showed up readily when I switched from using subs->Count in the loop test to a const variable that grabbed that value before the loop. The problem in this new case, and perhaps in my initial report I forget the context, was that I was calling Unsubscribe as I looped over the list. Similar to deleting an item from a container in an unsafe way while iterating over it. I avoided that issue by instead building up a list of symbols to delete, then iterating over that list to reacquire the contract pointer and unsubscribe from it. |
||||