Thread NamedDataSlot type discrepancy

agraham

Expert
Licensed User
Longtime User
However only two of the three will be really added in any case
In that case how using the same slot for b4p and cRunner. Then it will always be there and we won't get an exception (which is what I think happens) if we try to access the missing slot.
'optimized' flag could be useful even in cases where you don't need or have the knowledge of the more internal B4P or CRunner type.
Point taken!
 

agraham

Expert
Licensed User
Longtime User
No exception will be thrown.
I thought you were wrong but you're right as usual :)! I used the following code to test my libraries under 6.50 and 6.80 and without thinking about it assumed it was the slot access that threw an exception but of course is the cast to double that fails - silly me :(.
B4X:
try
{
  fixX = (double)(Thread.GetData(Thread.GetNamedDataSlot("fixX")));
  fixY = (double)(Thread.GetData(Thread.GetNamedDataSlot("fixY")));
}
catch
{
  // allows versions of b4p earlier than 6.80 to use this library
}
 
Last edited:
Top