title: How to run a method in the background only when app is open and running?
body: <p>Once the app is <strong>open and running</strong> I would like a background process to check a database and to make an update depending on the data in the database. I would like to make this check every one minute. I only want this to happen when the app is in the foreground and in view of the user. </p>
  
  <p>Can someone give me some suggestions as to how I do this? I assume I can call a method from here but I'm not sure how to do this. Also I do not know how to stop or even if I need to manually cancel / stop the process. Would it cancel itself when the app is not in the foreground and restart when the app came back into the foreground?</p>
  
  <pre><code>public partial class App : Application
  {
  
     protected override void OnStart()
     {
        App.DB.InitData();
        MainPage = new Japanese.MainPage();
     }
  </code></pre>
  
  <p>But do I need to make this run on a different thread and if so how could I do that. </p>
  
  <p>Sorry if my question is not clear. Please ask and I can update if it doesn't make sense. </p>