Hey guys,
I have been working on an application (with an internal library for building plots, and an adapter that creates the SciChart ViewModel implementation). All of my code makes heavy use of .Net 4.5’s Async API.
What I’ve noticed is that invoking the constructor on a RenderableSeries without the Dispatcher triggers the STA InvalidOperationException in PresentationCore. (Note that this is all happening during ViewModel construction, and before any changes have been made to the UI).
Is there any guidance on which parts of the SciCharts API require use of the UI thread?
- dsantimore asked 11 years ago
- You must login to post comments
Hi there,
RenderableSeries are indeed FrameworkElements and need to be instantiated on the UI thread. I would suggest do this create a factory class which you can inject into your ViewModels via dependency injection. The factory should also have the application dispatcher (given at startup, or in a bootstrapper if you are using a framework such as Prism). That way your viewmodels work at runtime and remain testable at test-time.
By the way if you want to see the base classes for types in the SciChart library, take a look at our online documentation which details the class hierarchy.
Hope this helps!
Andrew
- Andrew Burnett-Thompson answered 11 years ago
-
Thanks. That was quick! I won't be implementing things in this way (I'm avoiding DI in this project) but it helps to know that you can't invoke a FrameworkElement's constructor without being on the UI thread (something new every day... ).
- You must login to post comments
Please login first to submit.