Thread NamedDataSlot type discrepancy

Discussion in 'Beta Versions' started by agraham, May 1, 2009.

  1. agraham

    agraham Expert Licensed User

    Thread.GetData(Thread.GetNamedDataSlot("cPPC") returns a Boolean in the IDE and a String when optimised compiled :(

    While you are about it how about putting a CRunner or b4p reference in a NamedDataSlot?
     
    Last edited: May 1, 2009
  2. Erel

    Erel Administrator Staff Member Licensed User

    Thanks agraham. It will be fixed (both will return a boolean).
    Three new values will be added:
    optimized - boolean which will be true for optimized compiled applications.
    CRunner
    b4p
     
  3. agraham

    agraham Expert Licensed User

    Is there a need for three? As b4p and CRunner are mutually exclusive you could use one slot named, say Host or B4P and do a GetType() on it to find out which and that also tells you if its optimised compiled or not!
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    There is no real need. However only two of the three will be really added in any case and the '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.
     
  5. agraham

    agraham Expert Licensed User

    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.
    Point taken!
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    No exception will be thrown. It will return a null value (getting a non exist slot creates a new slot).
    Anyway the preferred way should be to first check the optimized flag and then take the right value.
    I agree that there are other reasonable solutions to do it as well.
     
  7. agraham

    agraham Expert Licensed User

    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 :(.
    Code:
    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: May 2, 2009
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice