System.InvalidOperationException'

Using Dispatcher to update values in GUI elements from a background thread

Reading Time: 3 minutes. Quick tip: If you’re developing something like a WPF app and you’ll need to update values on the User Interface based on a long-running operation that runs in a background thread (like depicted in my other blog post right here – that post is for a full-trust SharePoint solution, but the basic principle is the same!), you’ll probably need to use Dispatcher, or otherwise you’ll run into issues with the GUI elements being owned by another thread, and therefore forbidding access to them. This can result in an error like this: An unhandled exception of type ‘System.InvalidOperationException’ occurred in WindowsBase.dll   […]