Skip to Content
Mastering Windows Presentation Foundation
book

Mastering Windows Presentation Foundation

by Sheridan Yuen
February 2017
Intermediate to advanced
568 pages
14h 19m
English
Packt Publishing
Content preview from Mastering Windows Presentation Foundation

Handling events

One of the most common causes of memory leaks appearing in an application is the failure to remove event handlers once objects are no longer needed. When we attach an event handler to an object's event in the usual way, we are effectively passing that object a reference to the handler and creating a hard reference to it.

When the object is no longer needed and could otherwise be disposed of, the reference in the object that raises the event will prevent that from occurring. This is because the garbage collector cannot collect an object that can be accessed from any part of the application code. In the worst case scenario, the object being kept alive may contain numerous other objects and so inadvertently keep them alive also.

The ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Windows Presentation Foundation - Second Edition

Mastering Windows Presentation Foundation - Second Edition

Sheridan Yuen

Publisher Resources

ISBN: 9781785883002Supplemental Content