title: Resuming and suspendig WinRT Camera App
body: <p>I have an app with three pages: <code>MainPage</code>, <code>Page2</code> and <code>Page3</code>. At <code>MainPage</code> I have my camera, at <code>Page2</code> I have the historical with the scans from MainPage, and my <code>Page3</code> has some infos about the app. My issue is when I Suspend and when I Resume it. It suspends ok, but when I press the resume button at Visual Studio LifeStyle Events I get the following error <code>A remote operation is taken longer then expected</code>. As you can see, my app is taking to much time to be resumed.</p>
  
  <p>At my <code>App.xaml.cs</code> I have this OnSuspending method:</p>
  
  <pre><code>public App()
  {
      this.InitializeComponent();
      this.Suspending += this.OnSuspending;
  }
  
  private void OnSuspending(object sender, SuspendingEventArgs e)
  {
      var deferral = e.SuspendingOperation.GetDeferral();
       deferral.Complete();
  }
  </code></pre>
  
  <p>And in my <code>MainPage</code> I have this Resuming Method:</p>
  
  <pre><code>public MainPage()
  {
      this.InitializeComponent();
      Application.Current.Resuming += App_resuming;
  }
  
  async void App_resuming(object sender, object 
  {
      if (Frame.Content == this)
      await InitializeCamera();
  }
  </code></pre>
  
  <p>I think I have to dispose my camera when I suspend the app, so I created an Suspend Method at <code>MainPage</code> also, where I dispose my camera</p>
  
  <pre><code>void App_suspending(object sender, Windows.ApplicationModel.SuspendingEventArgs e)
  {
     _mediaCapture.Dispose();
  }
  </code></pre>
  
  <p>So, just reformulating my question: What am I doing is right? What am I missing? Thanks. </p>