Reputation: 1398
This error appear only when I add these lines to my OnRender override method:
for (int i = 0; i < this.Width; i++)
{
dc.DrawImage(Gouttes[i].Bitmap, new Rect(i, Gouttes[i].Y, 1, Gouttes[i].Length));
}
and Visual Studio says me it comes from
new Application().Run(new MainWindow());
which work either...
Please help me: what cause that error and how to fix it ?
Thanks a lot to all that will help me :)
Upvotes: 2
Views: 1245
Reputation: 292565
DependencyObject
is a subclass of DispatcherObject
; these objects are tied to the thread that created them. You can't access their dependency properties directly from another thread. If you need a worker thread to access a dependency property of a DispatcherObject
, you need to use Dispatcher.Invoke
to invoke the action on the dispatcher thread.
Upvotes: 3