Login Page - Create Account

Support Board


Date/Time: Wed, 27 Nov 2024 16:33:02 +0000



Post From: C++ threads inside a ACSIL study?

[2023-02-09 09:12:41]
User431178 - Posts: 544
Verified...apparently *any* std::thread crashes SC even before you get to add it to a chart.

The use of threads is not the cause here, all you have verified is that improper use of threads can crash the program.

As per the answer above, when the study function returns (the thread goes out of scope), the thread destructor is called and as your thread is still in a joinable state, the standard behavior is for the thread destructor to immediately terminate the program.

Also, bearing in mind the fact that the SetDefaults block is executed when you open the Add Custom Study window, in other word before the study is actually added to a chart, carefully consider when exactly you should be performing your thread initializtion operations.

ACSIL Interface Members - Variables and Arrays: sc.SetDefaults
ACSIL Programming Concepts: Study Initialization/Unitialization

Your preceding examples are not very helpful as they don't give any clue about the context in which they are used, only that you are using them in a study function.