Cannot determine when a control can release resources when NavigationCacheMode is Required
See original GitHub issueConsider the case where you have a templated custom control, class CoolThing : Control
.
CoolThing
acquires some expensive resources when IFrameworkElement.Loaded
is invoked and releases them in IFrameworkElement.Unloaded
.
However, the acquisition and release of these resources is a bit slow. It would be nice to set NavigationCacheMode="Required"
in the Page
containing a CoolThing
and only unload those resources when we know we really don’t need them any longer. However, there is no event CoolThing
can subscribe to in order to be informed when the Page
is being ejected from the cache and CoolThing
can now release it’s resources.
Or is there? Perhaps it’s just not obvious.
There is also no property that informs CoolThing
that even though Unloaded
is invoked that the control will not be destructed and Loaded
may invoke again.
Is this just the way things are or is there something I’ve missed?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:8 (4 by maintainers)
Top GitHub Comments
@MikeHillberg I’m no longer working at the organisation where this is relevant but @gabrielbunselmeyer is. Nevertheless, if I remember correctly, if the process ends then the destructor will not be called? Perhaps, Gabriel can confirm this.
@gabrielbunselmeyer you might want to subscribe to this one too