The calling thread cannot access this object because a different thread owns it [duplicate]

Following code might help you solve the issue of updating a gui element from another thread :

Module level

delegate void updateCallback(string tekst);

This is the method to update your element :

private void UpdateElement(string tekst)
{
    if (element.Dispatcher.CheckAccess() == false)
    {
        updateCallback uCallBack = new updateCallback(UpdateElement);
        this.Dispatcher.Invoke(uCallBack, tekst);
    }
    else
    { 
//update your element here
    }
 }

Leave a Comment