Answer the question
In order to leave comments, you need to log in
Why can't I stop the animation?
Hello. There is a class with two methods:
async public void DisplayAnimation(Canvas canvas)
{
this.IsShowAnimation = true;
while (this.IsShowAnimation)
{
this.Draw(this.Angle, StartPoint, canvas);
await Task.Delay(20);
canvas.Children.Clear();
this.Angle += 3;
}
}
public void StopAnimation(Canvas canvas)
{
this.IsShowAnimation = false;
}
DisplayAnimation()
, then the animation starts to work correctly. But if I call after some time StopAnimation()
, then for some reason it continues to work, although, according to my logic, it should stop. What could be the problem? Answer the question
In order to leave comments, you need to log in
Give a link in the source code where exactly the code is in the version as given. What I saw in the code and in your example is not the same thing. The source starts and stops the timer. Your example is taken out of context, so it's hard to understand something from it.
I didn’t clone your code from github, but I noticed that ChebyshevMachine is a structure, not a class. I do not know the reason for this choice, but I can assume that this may be the problem. Put a breakpoint on the StopAnimation method and check that this is the same object that you started the timer on.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question