0

I am developing a surface hub application wherein I am running a timer when the application is going into the background. At a specific point of time , I need to show up a popup in the center of the screen irrespective the application state - Minimized or active.

How can I achieve this ?

Apoorv
  • 2,023
  • 1
  • 19
  • 42

1 Answers1

0

If you register an in-process background task with a time trigger, every time span the background task triggered it will invoke the OnBackgroundActivated event. So you may define the popup code inside this event. No matter your app is minimized or active the in-process background task will be triggered. For example:

Register:

public MainPage()
{
   this.InitializeComponent();
   var builder = new BackgroundTaskBuilder();
   builder.Name = "My Background Trigger";
   builder.SetTrigger(new TimeTrigger(15, true));      
   BackgroundTaskRegistration task = builder.Register();
}

Override OnBackgroundActivated event and show a simple popup.

protected async override void OnBackgroundActivated(BackgroundActivatedEventArgs args)
{
    base.OnBackgroundActivated(args);
    await new Windows.UI.Popups.MessageDialog("test").ShowAsync();
    //DoBackgroundWork(args.TaskInstance);
}
Sunteen Wu
  • 10,509
  • 1
  • 10
  • 21