Bug 27451 - WinPhone renderers should implement IDisposable
Summary: WinPhone renderers should implement IDisposable
Status: RESOLVED NOT_ON_ROADMAP
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows ()
Version: 1.3.4
Hardware: PC Windows
: Normal enhancement
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-02-26 07:01 UTC by Michael Rumpler
Modified: 2016-04-08 19:07 UTC (History)
5 users (show)

Tags: ac rendererers
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NOT_ON_ROADMAP

Description Michael Rumpler 2015-02-26 07:01:18 UTC
I'm not sure if this can be seen as bug. It's more a feature request.

All custom renderers on iOS and Android implement IDisposable and Dispose gets called as it should. So all resources can be closed.

Unfortunately on Windows Phone the renderers don't implement that interface. So I cannot free my resources in my custom WP renderers.

I tried to find some other event I can attach to.
FrameworkElement.Unloaded gets called when another page is pushed to the stack, so that would be too early.
In OnElementChanged in the renderer e.OldElement is always null on all platforms. So this can also not be used.
The best I could find is NavigationPage.Popped where I check if my Element is on the Page being popped and dispose of it if that is the case. But what if there is no NavigationPage?

The cleanest solution would be to simply implement IDisposable in all renderers. And of course also call Dispose if the Element/its renderer is not used anymore.
Comment 1 E.Z. Hart [MSFT] 2016-04-08 19:07:06 UTC
Thank you for your report. At this time there are no plans to implement any changes around this issue.

Warm regards,
Xamarin Forms Team