title: Async method on Application lifecycle events (e.g. Application_Closing)
body: <p>I'm trying to save app data when the app is closing/deactivating.
  In WP8 I used StorageFile, which only supports Async methods.</p>
  
  <p>The problem is (as I suspected and confirmed when reading <a href="http://blog.dotnetgator.com/2013/04/13/proceed-with-caution-windows-phone-8-app-lifecycle-events-vs-async-methods/" rel="nofollow">this article</a>), simply stated, that the OS lifecycle events and async methods don't mix well together. So, this does not work (even without async/await)</p>
  
  <pre><code>private async void Application_Deactivated(object sender, DeactivatedEventArgs e)
  {
       var dataSvc = SimpleIoc.Default.GetInstance&lt;ICachedDataService&gt;();
       await dataSvc.StoreCachedDataAsync();
  }
  </code></pre>
  
  <p>The article suggests 2 workaround, neither one seems ideal:</p>
  
  <ol>
  <li>Use a different API, e.g. IsolatedStorage instead of StorageFolder/File, which supports synchronous operations.</li>
  <li>Save-as-you-go vs. save in the end</li>
  </ol>
  
  <p>My problem with (2) is that it still doesn't guarantee that it would have time to save even if I initiate it as soon as possible.</p>
  
  <p>My problem with (1) is... beh...  I'm using a ServiceLocator/IoC pattern (I could never remember which pattern is what), so this forces me to introduce synchronous operations in the interface of <code>ICachedDataProvider</code>, for example.</p>
  
  <p>Is there any other approach? Is it possible to convert an Async method into a synchronous method to increase code reuse?</p>