// 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) { BlueBrush = (SolidColorBrush)Application.Current.Resources["PhoneAccentBrush"]; //BlueColorBrush"]; APIErrorHandler = new APIErrorHandler(); LongPollService = new LongPollService(); PushNotifications = new PushNotifications(); UpdatesService = new UpdatesService(); EntityService = new EntityService(); }
// 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 (LongPollService == null) LongPollService = new LongPollService(); if (PushNotifications == null) PushNotifications = new PushNotifications(); if (APIErrorHandler == null) APIErrorHandler = new APIErrorHandler(); if (UpdatesService == null) UpdatesService = new UpdatesService(); if (EntityService == null) EntityService = new EntityService(); if (!_settings.IsPushOn) { // If timer has gone, so we can turn on Push notifications. if (DateTime.Now >= _settings.PushTurnOnTime) { _settings.IsPushOn = true; App.Current.PushNotificationsSwitchTimer.Dispose(); } else { // Turn on push notifications when time occurs. TimeSpan temp = _settings.PushTurnOnTime - DateTime.Now; PushNotificationsSwitchTimer = new Timer(state => { _settings.IsPushOn = true; App.Current.PushNotificationsSwitchTimer.Dispose(); }, null, Convert.ToInt32(temp.TotalMilliseconds), -1); } } }