question

Upvotes
Accepted
66 4 7 12

Does the Eikon .Net Desktop API work in non WPF applications?

I get runtime errors when I call DataServices.Instance to retrieve IDataServices instance when I run the application from within a C# console application. Anything other than running it from within a WPF application does NOT work. Why is that the case and can this be remedied? I find using the Eikon Desktop .Net SDK API extremely limiting to run from within a WPF application. Can someone of the developers please comment whether something is missing or why I cannot run the APIs from within a Console Application, for example?

Thank you.

Matt

eikoneikon-com-apic#.netsdk
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

1 Answer

Upvotes
Accepted
38.1k 71 35 53

Yes, you can create a C# console application with Eikon .NET Desktop API. The examples are available at https://developers.refinitiv.com/en/api-catalog/eikon/-net-apis-for-use-in-custom-applications/download. You can try Usage Example Realtime Data API.

A console application requires the Windows message pump in order to dispatch the retrieved events.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Can you please clarify what you mean with a "Windows message pump" is needed? Can you give concrete example? As it stands I cannot even connect to Eikon from within a Console app.

I did but pushing frames via Dispatcher and more importantly, blocking unless invoking "Frame.Continue" is completely unacceptable and violates most every efficient coding principle.

A much better way is to use Dispatcher.BeginInvoke() like

     Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() =>
                {
                    _dataServices = DataServices.Instance;
                    _dataServices.StateChanged += DataServicesOnStateChanged;
                    _dataServices.Initialize("ReutersMarketDataPlugin");
                }));


But that still is extremely dirty. I was wondering whether another approach exists without having to use the UI thread or any message pumps.

Hi @HFTVOL,

There's no way around having to run Windows message pump. The reason is there's a COM layer underneath .NET assemblies you interact with. And this COM layer cannot dispatch event notifications without Windows message pump running on the same thread. If you don't like using Dispatcher frames, you can instead use System.Windows.Forms.Application.Run method to kick off Windows message pump.

@jirapongse.phuriphanvichai,

I ran "DataApiUsageExampleTimeseriesData" in your referenced sample library.

How would I have to structure the Message Pump if I wanted to initialize ONCE but request "TimeSeriesRequest();" a second time without having to initialize the whole connection to Eikon again? That does not seem to work. Do I need to create a new DispatcherFrame, then submit a Reuters request, and then push the frame into the pump? Is that what I have to do for every request? And the code blocks on any callbacks from the Reuters API unless I set Frame.Continue to false. Is that correct?

There is an example available in this question. The example creates a new DispatcherFrame for the new request. However, you can use the same DispatcherFrame by setting Frame.Continue to true and then calling Dispatcher.PushFrame(Frame) again.

Click below to post an Idea Post Idea