문제

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 :)

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top