I am trying to use the custom sidebar example fetched here in the forum to develop my own indicator, which should take the state of a radio button as input. I have two radio buttons, "Long Position" and "Short position".
They are created in code and load well. In order to get the checked status of these radio buttons, the code of the logic of the indicator however needs to use the dispatcher, which I can't seem to get to work.
I wrote the async call like this (it lives in the OnBarUpdate event of the indicator):
int longShortSwapper = 0; // local variable to hold 1 or -1 for long/short math processing
bool? longOrShort = false; // local variable to hold the status of the radio button for later checks
// check if the current object is already on the calling thread
if (radioLong != null)
{
if (radioLong.Dispatcher.CheckAccess())
{
// execute action directly
longOrShort = radioLong.IsChecked;
}
// otherwise run the action from the thread that created the object
else
{
// dispatch action to calling thread
Dispatcher.InvokeAsync(new Action(() => {
System.Diagnostics.Debugger.Break();
longOrShort = radioLong.IsChecked;
}));
}
}
I am sorry if this is too basic, but I am unable to solve this without help...
Thank you,
Libor
Comment