Question

I have an app that has a BG module which is forced to run at every 4 mins for testing purpose, and it works fine. Once I launch the app(first launch) and register with the server the contents are displayed and I exit the app. The app goes to Application_Closing() state. I wait for a while(say about 15 mins) and try to launch the app, sometimes it so happens that, after the MainPage() constructor is executed, the app gets deactivated and while debugging and from the logs I observed that the app goes to Application_Deactivated() state.Basically, the app launches, its still displaying the Splash Screen(Customized) and it terminates all of a sudden. So, after I went through the log there is one question that is bothering me, i.e., if an app is launched while still the BG task is doing its job, and there is a conflict between the FG and the BG task will that in anyway result in Application Deactivation? I also have doubt that I must be doing something more inside the Application_Deactivated() method in the APp.xaml.cs class. Here is the Code.

   private void Application_Deactivated(object sender, DeactivatedEventArgs e)
    {
        Logger.log(TAG, "Application deactivated");
    }
    // Code to execute when the application is closing (eg, user hit Back)
    // This code will not execute when the application is deactivated
    private void Application_Closing(object sender, ClosingEventArgs e)
    {
       if (appSession != null)
        {
            appSession.close();
        }
       Logger.log(TAG, "Application closed");
    }

//Log:-

Was it helpful?

Solution

From what I understand from your query, I can conclude that since the Application is running in the BG thread before it is launched, its unable to allocate UI resources which require it to be on the FG (which is not happening due to the cross threading issue). I guess you need to sort out this conflict before you proceed.

Note: I am not sure about this. Its only an observation. Hope my answer helps you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top