Example #1
0
        public static async Task PopulateStationsCache()
        {
            if (StationsCache.Stations != null)
            {
                return;
            }

            if (File.Exists(StationsCache.cachePath))
            {
                IList <Station> stationsFromFile = FetchStationsFromFile();
                StationsCache.Stations = stationsFromFile;
            }

            if (StationsCache.Stations != null)
            {
                Console.WriteLine("Populated stations cache from file system.");
                return;
            }

            IList <Station> stationsFromServer = await FetchStationsFromServer();

            StationsCache.Stations = new Collection <Station>(stationsFromServer);
            Console.WriteLine("Populated stations cache from web service.");

            // TODO: Write file cache asynchronously?
            StationsCache.WriteFileCache(stationsFromServer);
        }
Example #2
0
        public override void DidEnterBackground(UIApplication application)
        {
            // Use this method to release shared resources, save user data, invalidate timers and store the application state.
            // If your application supports background exection this method is called instead of WillTerminate when the user quits.

            Console.WriteLine("DidEnterBackground: Clearing stations cache.");
            StationsCache.ClearStationsCache();
        }
Example #3
0
        public override void DidReceiveMemoryWarning()
        {
            base.DidReceiveMemoryWarning();

            // Release any cached data, images, etc that aren't in use.
            Console.WriteLine("DidReceiveMemoryWarning: Clearing stations cache.");
            StationsCache.ClearStationsCache();
        }
Example #4
0
        public async override void OnActivated(UIApplication application)
        {
            // Restart any tasks that were paused (or not yet started) while the application was inactive.
            // If the application was previously in the background, optionally refresh the user interface.

            Console.WriteLine("OnActivated: Populating stations cache.");
            await StationsCache.PopulateStationsCache();

            Console.WriteLine("OnActivated: Populated stations cache.");
        }