====
Strategy 'myStrat01': Error on calling 'OnBarUpdate' method on bar 53216:
The calling thread cannot access this object because a different thread owns it.
====
I can't find a way to resolve it and tried different things but to no avail.
Here is what i do...
My strategy displays a series of buttons created during the initialization phase (State.DataLoaded phase).
The error occurs when i try to change the background attribute of some of the buttons during the OnBarUpdate()
Ex.
protected override void OnBarUpdate()
...
#region DoSomeCleanUp_WhenTradeIsOver
//-
if ( IsTradeInProgress && (atmStrategyId.Length + orderId.Length) == 0 )
{
IsTradeInProgress = false;
isAtmStrategyCreated = false;
buttonSell.Background = Brushes.DarkSlateGray; // <- this line raises an error
sellModeEnabled = false;
buttonBuy.Background = Brushes.DarkSlateGray; // <- this line raises an error
buyModeEnabled = false;
}
}
//-
#endregion
If i remove the faulty lines in Bold then everything works perfectly.
Do you have something to suggest to change the background color during the OnBarUpdate. I tried to Freeze the colors but it did not help.
Thanks

Comment