This is a method to split an order into 2.
I am getting different values out - when the method is called - to those worked out inside the method.
If I call a second time I get the correct value.
The values a and b inside the method are always correct!!
Its set to OnEachTick and I have printed what the method produces which is correct. But the "Out" part seems to hang on to the prior value?
Here's an example
Quantity Selector = 50
Q0 output = 16 - called outside the method
Q1 output = 17
a = 25
b = 25
Quantity Selector = 29
Q0 output = 25
Q1 output = 25
a = 15
b = 14
Any help appreciated.
#region SetOrderQuantity()
private void SetOrderQuantity(out int Q0, out int Q1)
{
ChartControl.Dispatcher.InvokeAsync((Action)(() =>
{
if(quantitySelector.Value >=2)
{
if(quantitySelector.Value % 2 ==1)
{
a = (quantitySelector.Value * 0.5 + 0.5);
}
else
{
a = (quantitySelector.Value* 0.5);
}
b =quantitySelector.Value - a;
}
else
{
a = 1;
b = 0;
}
Print("a = "+a.ToString());
Print("b = "+b.ToString());
}));
Q0 = (int)b;
Q1 = (int)a;
}
#endregion

Comment