Hi All,
I'm developing a metro app.
I'd like to know when my app is running in the background so that if a user completes an action that needs to be synced with a server, they can do so in offline mode and when the app is in the background I'd like to be able to try and sync say every minute, or detect when they are online.
I've tried to use:
public HomeScreen()
{
this.InitializeComponent();
Window.Current.VisibilityChanged += Current_VisibilityChanged;
}
void Current_VisibilityChanged(object sender, Windows.UI.Core.VisibilityChangedEventArgs e)
{
if (!e.Visible)
{
}
}
However this event seems to continuously fire when the app is the background. When the visibility (from an end users perspective) is not changing.
This wouldn't be too bad if there was an enumeration of states, such as; Backgound, Foreground. Etc.
I'm aware that you're able to query the visual state of the active window however this gives you information on the orientation of the windows, i.e. Snapped, Filled etc. There doesn't appear to be a way of telling if the form has lost focus (the user is interacting with another app/desktop) and then if that app is open
before being Suspended.
Many thanks for any input.
Larry.