title: Windows 10 UWP - stop background task if foreground app is running
body: <p>How I can prevent background task from running if there are foreground app being executed? Using Universal Windows Platform for my app. </p>
  
  <p>My background task is checking for new items on some site and sends a toast when there are new things available, but I wan't to prevent toast sending if user is running application right now.</p>
  
  <p>I have tried to unregister task on my application launch and register it again when app is terminated, through, this is not fine solution for me -- when device shuts down for some reason (for example, battery was removed) my task will be not registered until app launched again.</p>
  
  <p>Thanks.</p>