Setting the interval between drawing on canvas (C #)

Basically, I'm trying to draw a sequence of lines on a Canvas object with a short pause between each drawn line. Unfortunately, since I have it now, it pauses, but I do not see any intermediate steps, that is, I see it before and after, but nothing happens between them. I tried System.Timers.Timer, but it gave me an error stating that the canvas belongs to another thread. How can I make this work?

+3
source share
3 answers

Have you tried to put your drawing sequence into a storyboard? you can stop or start them at your discretion, or just go to them what you want.

+4
source

In WPF, I would recommend using System.Windows.Threading.DispatcherTimer instead.

http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatchertimer.aspx

+1
source

The controls in winforms do not play well with threads. There is a timer class specifically designed to work with winform controls.

http://msdn.microsoft.com/en-us/library/system.windows.forms.timer.aspx

It can be found in the toolbar in VS

0
source

Source: https://habr.com/ru/post/1777338/


All Articles