In Xamarin Forms I have the following class (with no content):
public class TracksBoxView : BoxView
// Uses custom renderer TracksBoxViewRenderer.cs
{
}
A ContentPage called TracksPage.cs, on a navigation stack, contains just TracksBoxView, a Label and a Switch. TracksPage generates some public data (takes a few seconds) then sets a flag that is being polled by the iOS custom renderer TracksBoxViewRenderer.cs. The custom renderer then retrieves and displays the information.
When the user navigates to TracksPage (push), the information is displayed correctly. The user then hits the 'back' button and after a few seconds navigates again to TracksPage. This is repeated. On about the second or third try, the following exception occurs:
System.ObjectDisposedException: Cannot access a disposed object.
This occurs early in the custom renderer at the following line:
double totalWidth = (double)this.Bounds.Width;
If the user delays 30 seconds or more between tries, it works most times. I imagine garbage collection is happening meanwhile.
Have not found anything similar in the forums.
Is there anything I can do about this, maybe a better way or a workaround? Does it sound like a Xamarin Forms bug?
thisis the source the disposed object error? Is thisTracksBoxViewwithin a recycler? - SushiHangover