0

I have the following code:

AddHandler aX.Completed, AddressOf AnimationCompleted

...

Private Sub AnimationCompleted(sender As Object, e As EventArgs)

      Dim ac As AnimationClock = sender
      Dim aX As DoubleAnimationUsingPath = ac.Timeline

      RemoveHandler aX.Completed, AddressOf AnimationCompleted

End Sub

Throws:

Specified value of type 'System.Windows.Media.Animation.DoubleAnimationUsingPath' must have IsFrozen set to false to modify.

How can I remove the event handler if the object is frozen? My concern is that if the event handler is not removed the animation object will not be properly garbage collected.

apc
  • 5,306
  • 1
  • 17
  • 26
  • 1
    Removing the event handler is not necessary. See [this answer](http://stackoverflow.com/a/298276/1136211). – Clemens Apr 13 '16 at 10:13
  • Is this the case in WPF? I know there are instances in WPF if you don't remove the event handler of a control then the control is not removed even though it is no longer in the Window. – apc Apr 13 '16 at 10:27
  • We're talking about a regular .NET event here, so the answer should be applicable. – Clemens Apr 13 '16 at 10:29

0 Answers0