question

Upvotes
Accepted
97 2 4 10

Eikon .NET API DispatcherFrame

I am building an application that will use eikon .net api along with redi api.

I need to process pricing in the background thread and call subscription as needed. I googled 'DispatcheFrame' but still not clear how I should be structuring my code.

1. Current example creates/starts subscription and then calls Dispatcher.PushFrame() which stops code from executing next line. How do I add new subscriptions?

2. Any problem if I were to wrap this in a worker thread? It seems to work but not sure whether it will cause problem.

I'd appreciate advice on how I should be structuring the code in multi threaded environment. Currently, I am testing it in the console app but eventually it will be a gui app.

eikoneikon-data-apieikon-com-api.netdispatcherdispatcher-frame
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.

Upvotes
Accepted
39.2k 75 11 27

In addition to the response from @Zhenya Kovalyov, I would very strongly recommend implementing all data retrieval on a single thread. It can very well be a worker thread, but it should be a single thread and Windows message pump must be running on this thread. In a GUI application it's best to do all data retrieval on the GUI thread.

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.

Upvotes
4.6k 26 7 22

@39783854-26aa-4fea-bc93-00b2ec21f8bb the .NET api requires manual pumping of the event loop, DispatcherFrame is just a replacement for Application.DoEvents(). In the console app context (sample apps) it is required, so program is prevented from exiting before the event arrives.

I do not think using it in a multi-threaded environment is going to cause problems.

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.

Upvotes
97 2 4 10

I can have a separate thread create and process all the message. However, if I want to change subscriptions should I have reference to subscription object from other thread and directly update? (subscription.AddRic/etc)

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.

Click below to post an Idea Post Idea