3

Bloomberglp.Blpapi.Session has a constructor that looks like this:

public Session(SessionOptions, Bloomberglp.Blpapi.EventHandler, EventDispatcher);

The EventDispatcher class looks like this:

public sealed class EventDispatcher
{
    public bool Start();
    public void Stop();
    public void Stop(EventDispatcher.StopOption stopOption);
    public void DispatcherThread();
    public int NumActiveThreads { get; }
    public enum StopOption { SYNC, ASYNC }
}

In code I use it like:

Session session = new Session(sessionOptions, someEventHandler.Handle, new EventDispatcher(2));

Do I understand this correctly that this simply tells the Session instance to use the dispatcher when an event occurrs to delegate the Event to the provided someEventHandler.Handle(Event, Session) method?

What are the Start(); Stop(); and DispatcherThread() methods for?

The EventDispatcher is not documented anywhere so maybe someone has some experience with this.

Picrofo Software
  • 5,475
  • 3
  • 23
  • 37
tweakch
  • 426
  • 3
  • 13
  • 1
    I see how this could be useful: If you have two type of `Requests` (one is asking for `Bid`, `Ask` fields, the other one is returning portfolio information), then having just __one__ thread dispatching the `Response` would increase the latency for the small responses on the session. – tweakch Nov 29 '12 at 13:35
  • in that case you can simply use 2 sessions (which is the recommended way in the documentation). – assylias Dec 05 '12 at 18:45

2 Answers2

1

Presuming you have access to a Bloomberg Terminal, you should ask the Bloomberg Helpdesk.

Basically, what you're doing is not the 'recommended' approach - i.e. that which is demonstrated in the tutorials. In such an approach, you can simply use:

Session session = new Session(sessionOptions);

But it sounds like you've already got the documents... so why are you trying to use your own EventDispatcher?

amaidment
  • 6,942
  • 5
  • 52
  • 88
  • That's the synchronous session scenario. But I need to use an asynchronous session instance for which there are two constructors. One takes the `SessionOptions` together with an `EventHandler` delegate. I know how that one works. I'm interested in the third one, described in my answer. – tweakch Dec 04 '12 at 16:54
0

The purpose of the EvevtDispather that you can create it manually with required number of threads then you can pass it for as many Session as you want. All of them will use your dispather to handle events. Otherwise every new Session will create its own event dispatcher internally with one thread. So if you have big amount of non-intensive sessions it's wise decision to create only one event dispather for them.

inkooboo
  • 2,904
  • 1
  • 19
  • 24