cTrader Beta 4.2 Threading Issue

Created at 03 Apr 2022, 17:24
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
ClickAlgo's avatar

ClickAlgo

Joined 05.02.2015

cTrader Beta 4.2 Threading Issue
03 Apr 2022, 17:24


Hi Team,

After testing a few of our products that use a custom UI with Windows Forms and Syncfusion it looks like v4.2 of cTrader now uses multithreading or a different threading model than the one before, many of our products call the UI's using a single apartment thread, this no longer works in 4.2 and an error message states we should use BeginInvokeOnMainThread

Our current method of calling an STA application is:

.

.

This has worked very well for all applications over the past 5-years or more with no memory leaks or performance issues on the platform.

.

PROBLEM

The problem is that the platform throws the BeginInvokeOnMainThread error and no data is being returned from the passed in Robot object, so no data gets updated, in the example above if the STA model is used the OnPositionsOpened method never gets used.

.

POSSIBLE SOLUTION

We have found a possible workaround to call the UI components using the following block of code.

.

.

This works fine apart from any ActiveX or STA controls on the form.

.

AREAS OF CONCERN

I am sure many vendors have also used the STA model to call applications to run on the cTrader platform, we could go through all our products and get them working for v4.2 with the BeginInvokeOnMainThread call and we would have to test each product on both 4.1 and 4.2 so the next update is seamless to the customer.

My question is is it possible to offer backward compatibility for the previous single threading apartment calls or do all vendors need to update their code for the new multi-threading model?

If you could treat this with urgency as it would be good to have a solution before v4.2 starts to be rolled out to brokers.


@ClickAlgo
Replies

amusleh
04 Apr 2022, 11:22

Hi,

We were able to reproduce this issue and it will be fixed on next release of beta version, thanks for reporting!


@amusleh