The calling thread cannot access this object because a different thread owns it.
Posted: 07 Aug 2019, 18:03
I'm trying to render a CustomCanvas view programmatically
I'm calling this method from another class but it's giving me this error What's the fix for this?
Code: Select all
public class GraphCanvas : Canvas {
...
public void renderGraph()
{
Rectangle rect = new Rectangle();
rect.Width = 200;
rect.Height = 100;
rect.Fill = Brushes.Blue;
this.Children.Add(rect);
}
}
Code: Select all
renderGraph();
Code: Select all
The calling thread cannot access this object because a different thread owns it.