Please, consider this simple function:
public void BeginFade()
{
var fade = new DoubleAnimation(0d, TimeSpan.FromSeconds(1));
fade.Completed += Fade_Completed;
grid.BeginAnimation(OpacityProperty, fade);
}
The scope of var fade
is the function BeginFade
and as far as I understand when the DoubleAnimation
class has completed its task, the Framework will clear the resources automatically.
Is this correct?
And what about the event handler? When I call more times BeginFade()
what happens to the event Completed
?
This example is just to better understand the underlying behaviors. Of course I might declare fade
as a class member and set the event Completed
in the constructor...