Prevent concurrent access errors when iterating over news events during rendering

This commit is contained in:
moshferatu 2024-07-04 19:38:47 -07:00
parent ccb420e519
commit 20768cebac

View File

@ -234,7 +234,7 @@ namespace NinjaTrader.NinjaScript.Indicators
// Draw news events.
using (TextFormat eventTextFormat = EventFont.ToDirectWriteTextFormat())
{
foreach (var newsEvent in newsEvents)
foreach (var newsEvent in new List<NewsEvent>(newsEvents))
{
var timeSize = MeasureString(newsEvent.Time, eventTextFormat);
var currencySize = MeasureString(newsEvent.Currency, eventTextFormat);