API Support Forum
OEC API > API Support > Multiple client_OnBarsReceived per RequestBars call
Author Topic: Multiple client_OnBarsReceived per RequestBars call
(3 messages, Page 1 of 1)
Moderators: VPfau
DRichards310
Posts: 2
Joined: Dec 05, 2011


Posted: Dec 06, 2011 @ 09:59 PM             Msg. 1 of 3
Hi,

I seem to be experiencing a problem where I recieve multiple events for each call I make. Is this normal?

A common thing I am seeing;
RequestBars
client_OnBarsReceived
RequestBars
client_OnBarsReceived
client_OnBarsReceived
client_OnBarsReceived
client_OnBarsReceived
client_OnBarsReceived

I use my own ThreadingPolicy class, but basically all I do in Post is call action() inside the worker thread you are giving me so I cannot see how that could cause this. This is a service app and so I am unable to use you normal synchronization context that queues to the windows UI thread loop.

Dave Richards
DRichards310
Posts: 2
Joined: Dec 05, 2011


Posted: Dec 06, 2011 @ 10:07 PM             Msg. 2 of 3
I also tried simply changing post to
public void Post(APIAction action)
{
var thread = new Thread(() => { action(); });
thread.Start();
}

just to put it on a different thread, but to no effect.

Dave Richards
RuslanK
Posts: 69
Joined: Jun 02, 2010


Posted: Dec 07, 2011 @ 08:07 AM             Msg. 3 of 3
Hello,

The answer to your first question is: Yes, it is completely normal behavior.
Once you request bars we sending them back to you in "packets" - usually 4096 per event.
We also send empty packet (zero bars) at the end of series to signal you that no more historical data will come for this request.

Please pay your attention to the fact that API does not support multithreading, so please avoid making calls of API from different threads - it is supposed to work in single thread appartment model only.

Let me know if you have any questions.

Ruslan Kartokhin
Software Developer