Ejemplo n.º 1
0
        // Code to execute when the application is launching (eg, from Start)
        // This code will not execute when the application is reactivated
        private void Application_Launching(object sender, LaunchingEventArgs e)
        {
            TileRefreshNeeded = true;

            InitializeLocations();
            RefreshTilesPinState();

            PushHandler = new PushHandler(Resources["PushStatus"] as Status, Locations, Dispatcher);
            PushHandler.EstablishConnections();
        }
Ejemplo n.º 2
0
        // Code to execute when the application is activated (brought to foreground)
        // This code will not execute when the application is first launched
        private void Application_Activated(object sender, ActivatedEventArgs e)
        {
            if (!e.IsApplicationInstancePreserved)
            {
                // The application was tombstoned, so restore its state
                foreach (var keyValue in PhoneApplicationService.Current.State)
                {
                    Locations[keyValue.Key] = keyValue.Value as LocationInformation;
                }

                // Reconnect to the MSPN
                PushHandler = new PushHandler(Resources["PushStatus"] as Status, Locations, Dispatcher);
                PushHandler.EstablishConnections();
            }
            else if (!PushHandler.ConnectionEstablished)
            {
                // Connection was not fully established before fast app switching occurred
                PushHandler.EstablishConnections();
            }

            RefreshTilesPinState();
        }