title: 'Cannot access a disposed object' in Xamarin Forms custom renderer
body: <p>In Xamarin Forms I have the following class (with no content):</p>
  
  <pre><code>public class TracksBoxView : BoxView
  // Uses custom renderer TracksBoxViewRenderer.cs
  {
  }
  </code></pre>
  
  <p>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.</p>
  
  <p>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:</p>
  
  <pre><code>System.ObjectDisposedException: Cannot access a disposed object.
  </code></pre>
  
  <p>This occurs early in the custom renderer at the following line:</p>
  
  <pre><code>double totalWidth = (double)this.Bounds.Width;
  </code></pre>
  
  <p>If the user delays 30 seconds or more between tries, it works most times. I imagine garbage collection is happening meanwhile.</p>
  
  <p>Have not found anything similar in the forums.</p>
  
  <p>Is there anything I can do about this, maybe a better way or a workaround? Does it sound like a Xamarin Forms bug?</p>