I created two different MarketData objects with different handlers in different classes. They each subscribed to different instruments. I ended up with strange bugs because I never bothered to check the instrument being passed. I eventually tested the instrument against what I expected and found that sometimes one of them would be called with market updates for the other instrument.
MarketData dataForA = new MarketData(instrumentA); dataForA.Update += UpdateHandlerForA; // some time passes before this is created by a different object. MarketData dataForB = new MarketData(instrumentB); dataForB.Update += UpdtaeHandlerForB; void UpdateHandlerForA(...) { // recieves some of the B events but only after B is created and subscribed } void UpdateHandlerForB(...) { // only seems to receive events for B }
This only seems to happen on first subscribing to the MarketData event, and only seems to happen for the first MarketData object created between the two. In the above example it only seems to affect dataForA, and not dataForB.
Comment