I have some UI code that needs to be updated from my background presenter thread. So, I do the following: from my background thread, I set my property in the UI: _ui.ConnectionStatus = "A";
then, my set is as follows:
public string ConnectionStatus
{
set{
if (Dispatcher.CheckAccess())
ConnectionStatusTxt.Content = value;
else {
Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() =>
{ConnectionStatusTxt.Content = value;}));
}
} }
I get the following error: "The calling thread cannot access this object because a different thread owns it." My understanding was that Dispatcher takes care of invoking on different threads, so this error puzzles me a little. Thanks!