开发者

Setting an Interval between draws on a Canvas (C#)

开发者 https://www.devze.com 2023-01-27 13:17 出处:网络
Basically I\'m trying to draw a sequence of lines on a Canvas object with a short pause in between each line being drawn. Unfortunately as I have it now it does pause but I don\'t see any of t开发者_如

Basically I'm trying to draw a sequence of lines on a Canvas object with a short pause in between each line being drawn. Unfortunately as I have it now it does pause but I don't see any of t开发者_如何学JAVAhe intermediate steps, which is to say I see it before and after it's drawn but nothing in between. I've tried System.Timers.Timer but it gave me an error that said the canvas was owned by another thread. How can I get this to work?


have you tried putting your drawing sequence in a storyboard? you can stop/start them pretty much at will, or just time them to what you want.


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

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


Controls in winforms do not play nice with threads. There is a timer class specifically made for working with winform controls.

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

It can be found in your toolbox in VS

0

精彩评论

暂无评论...
验证码 换一张
取 消