question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot determine when a control can release resources when NavigationCacheMode is Required

See original GitHub issue

Consider 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:open
  • Created 3 years ago
  • Reactions:4
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
phraemercommented, Feb 9, 2021

@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.

1reaction
phraemercommented, Jan 8, 2021

@gabrielbunselmeyer you might want to subscribe to this one too

Read more comments on GitHub >

github_iconTop Results From Across the Web

WinRT/UWP Frame and Page caching: How to create new ...
My problem is the Frame control: If I use it without NavigationCacheMode = Required , every time the user goes back, the page...
Read more >
Page.NavigationCacheMode Property (Windows.UI.Xaml. ...
Gets or sets the navigation mode that indicates whether this Page is cached, and the period of time that the cache entry should...
Read more >
NavigationPageCache Support and Limitations
Determining when a control can release resources when NavigationCacheMode is Required: · Is it expected that x:DeferLoadStrategy changes order of loading?:
Read more >
NavigationFrame keeps views with defined services in ...
NavigationFrame keeps views with defined services in memory even if the NavigationFrame.NavigationCacheMode property is set to Disabled.
Read more >
Navigation Using the Prism Library for WPF
Implementing the required navigation behavior in a Windows Presentation Foundation (WPF) ... In many cases, the region control will be a simple control, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found