-
I want some code running in the background to be able to raise information to the window as basically a one-line log
I had initially implemented this with FeedbackTextColor being a SolidColorBrush since the intellisense told me that Foreground should be an IBrush. This worked fine until the first time I updated it from a non-UI thread at which point I got "System.InvalidOperationException: Call from invalid thread". Switching FeedbackTextColor from a SolidColorBrush to a string and using things like "#FF0000" instead of SolidColorBrush(Colors.Red) makes the error go away with no other code changes. Why does creating a binding to a SolidColorBrush cause errors when I update the value outside of a UI thread as I would any other bound value? Are there other variable types that I need to watch out for and avoid using for bindings (or should I make sure to stick to just the basics - ints, strings, and the like)? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Updating the UI from a non-UI thread is a no-no-no... Edit: Windows WPF ` public static class Dispatch
} |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
SolidColorBrush
is a UI object that maintains change listeners, that has to be created on UI thread.ImmutableSolidColorBrush
is an immutable version that can be created on any thread.