cTrader Beta 4.2 Threading Issue
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.
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