我正在尝试使System.Windows.Forms.Timer在动画后工作。
private Timer timer1 = new Timer();
protected override void OnLoad(EventArgs e)
{
timer1.Interval = 25;
timer1.Tick += timer1_Tick;
tempX = this.Location.X;
new Animator2D(new Path2D(-300, 23, this.Location.Y, this.Location.Y, 1500, AnimationFunctions.ExponentialEaseOut))
.Play(this, Animator2D.KnownProperties.Location, new SafeInvoker((() =>
{
timer1.Enabled = true;
})));
base.OnLoad(e);
}
我用这种方法。
但没用
所以我改变了方法。
private Timer timer1 = new Timer();
protected override void OnLoad(EventArgs e)
{
timer1.Interval = 25;
timer1.Tick += timer1_Tick;
tempX = this.Location.X;
new Animator2D(new Path2D(-300, 23, this.Location.Y, this.Location.Y, 1500, AnimationFunctions.ExponentialEaseOut))
.Play(this, Animator2D.KnownProperties.Location, new SafeInvoker((() =>
{
Invoke(new Action(() => timer1.Enabled = true));
})));
base.OnLoad(e);
}
它起作用了。
我不知道两种方法的区别。
通过调试器,即使使用第一个方法,timer1的启用值也将更改为True。
我想知道为什么会这样。