Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
XAMCalculationManager crashes when used in multiple threads

I have an application the uses multiple UI threads for performance reasons.  I notice that If i instantiate a XAMCalculationManager from these different threads I will get an exception about an object being used from a different thread than the owning thread.  It seems like maybe the XAMCalculationManager has some static data that it is attaching to the first UI thread that calls it.  Is there any workaround for this?

No Data
  • 34510
    Offline posted

    Hi John,

    Unfortunately you are right about the static data.  The xamCalculationManager refers to a static class called SR which manages string resources.  This is probably what is causing the exception.  I can confirm this if you were to send me a call stack for the thread exception so I can see what line it's crashing on.

    I'm not sure what workaround you could use for this.  There's nothing you can really do about this short of making sure that only one thread is creating and using the calculation manager.  The more proper solution would be for us to change how we handle these string resources all together in the source code and I would say that's more of a product idea.  You can submit this as a product idea here:

    Maybe you could keep a single calculation manager on 1 thread and call into it via Dispatcher.BeginInvoke() so that the calls remain on that 1 thread, then somehow pass the result back to the calling thread to evaluate it?

No Data