locked
How to detect app going to background? RRS feed

  • Question

  • Since background audio keeps app alive, there will be no suspend event.

    I need to detect "app going to background - who knows what will happen" event: So i can pause or stop some of the threads those should not be working while the app is not visible (even if it is running in the background meanwhile)

    Friday, September 21, 2012 6:58 PM

Answers

  • you can use the VisibilityChanged for this purpose:

    Window.Current.VisibilityChanged += (s, e) => 
    {
        if (!e.Visible)
        {
            // Application went to background
        }
        else 
        {
            // Application is FullScreen again
        }
    };
    


    Can Bilgin
    Blog CompuSight

    • Proposed as answer by Can Bilgin Tuesday, September 25, 2012 3:21 PM
    • Marked as answer by Min ZhuMember Thursday, October 4, 2012 9:13 AM
    Friday, September 21, 2012 7:01 PM

All replies

  • you can use the VisibilityChanged for this purpose:

    Window.Current.VisibilityChanged += (s, e) => 
    {
        if (!e.Visible)
        {
            // Application went to background
        }
        else 
        {
            // Application is FullScreen again
        }
    };
    


    Can Bilgin
    Blog CompuSight

    • Proposed as answer by Can Bilgin Tuesday, September 25, 2012 3:21 PM
    • Marked as answer by Min ZhuMember Thursday, October 4, 2012 9:13 AM
    Friday, September 21, 2012 7:01 PM
  • you can use the VisibilityChanged for this purpose:

    Window.Current.VisibilityChanged += (s, e) => 
    {
        if (!e.Visible)
        {
            // Application went to background
        }
        else 
        {
            // Application is FullScreen again
        }
    };
    


    Can Bilgin
    Blog CompuSight

    Thank you this seems to solve my problem and there is no way to detect app is going to background?
    Friday, September 21, 2012 7:04 PM
  • The manner what Can provided is the way how to do

    Friday, September 21, 2012 9:44 PM