Is the class IndicatorDataSeries thread safe?
Is the class IndicatorDataSeries thread safe?
10 Feb 2020, 01:29
Hello!
I have to perform some calculations in the background thread.
Is the class IndicatorDataSeries thread safe?
Is it safe to update IndicatorDataSeries objects from outside of Calculate(...) `s thread?
Regards,
Replies
koktos632
10 Feb 2020, 08:44
RE: RE:
firemyst said:
Here's a quick code example of what you might put in both the Calculate and your other methods to control the locking.
Thank you for the example.
The questions is still not answered.
2 support:
Is the class IndicatorDataSeries thread safe?
Could you answer, please?
@koktos632
PanagiotisCharalampous
10 Feb 2020, 09:03
Hi koktos632,
No it is not.
Best Regards,
Panagiotis
@PanagiotisCharalampous
koktos632
10 Feb 2020, 09:43
RE:
PanagiotisCharalampous said:
No it is not.
Add it to docs, please.
Thank you!
@koktos632
firemyst
10 Feb 2020, 04:45
RE:
koktos632 said:
I do all the time as long as the index you're modifying isn't the current index as per the parameter in the Calculate method. This is because unless you implement locking, the calculate method could try and update the index the same time you are.
Here's a quick code example of what you might put in both the Calculate and your other methods to control the locking.
Create your own "_lockObject" at the global class level.
The below code will try to enter and perform the actions within the try/finally block. It will wait for the amount of milliseconds specified to acquire the lock. If it can't, it will skip the code; otherwise the code will execute.
@firemyst