SlideShare a Scribd company logo
Fast Application
Switching &
Tombstoning
Topics
   The Windows Phone execution model
   Application State Management
   Fast Application Switching
   Dormant programs and Tombstoning
   Application Navigation and Application Switching




2   Windows Phone
Demo


Demo 1:
Fast Application
Switching
Application Lifecycle - Dormant
                                                     Fast App Resume


                                   running
State preserved!
e.IsApplicationInstancePreserved                                Save State!
== true




                      activated                deactivated




                                   dormant   Phone resources
                                             detached
                                             Threads & timers
                                             suspended
  4   Windows Phone
Application Lifecycle - Tombstoned
                                                                 Resuming .. .
Restore state!
e.IsApplicationInstancePreserved
== false
                                        running




                            activated              deactivated

 Tombstone
 the oldest
 app

               Tombstoned               dormant   Phone resources detached
                                                  Threads & timers suspended

  5   Windows Phone
Methods & Events




6   Windows Phone   6
Finding the Resume type
    private void Application_Activated(object sender, ActivatedEventArgs e)
    {
        if (e.IsApplicationInstancePreserved)
        {
            // Dormant - objects in memory intact
        }
        else
        {
            // Tombstoned - need to reload
        }
    }




   The Activation handler can test a flag to determine the type of resume
    taking place


7    Windows Phone
Deactivation Resource Management

                           MediaPlayer.Pause
                           MediaElement.Pause
                       SoundEffectInstance.Pause
                        VibrateController.Stop
                          PhotoCamera.Dispose
                          Save page/global state


                    XNA Audio      Paused
                    Sensors        Notifications suppressed
                    Networking     Cancelled
                    Sockets        Disconnected
                    MediaElement   Disconnected
                    Camera         Disposed

8   Windows Phone
Activation Resource Management

                    MediaElement.Source/Position/
                                 Play
                    Socket.ConnectAsync
                    new PhotoCamera/VideoCamera

                    Restore app state if tombstoned


                    XNA Audio      Resumed
                    Sensors        Notifications resumed
                    Networking     Completed with Cancellation
                    Sockets        -
                    MediaElement   -
                    Camera         -
9   Windows Phone
Isolated Storage vs State Storage

 Isolated storage is so called because the data for an application is
  isolated from all other applications
      It can be used as filestore where an application can store folders
       and files
      It is slow to access, since it is based on NVRAM technology
      It can also be used to store name/value pairs, e.g. program
       settings
 State storage is so called because it is used to hold the state of an
  application
      It can be used to store name/value pairs which are held in memory
       for dormant or tombstoned applications
      It provides very quick access to data


1
    Windows Phone                             10
0
Captain’s Log



Demo
•   With No Storage
•   With Storage
•   Fully Working
Fast App Switching and
Tombstoning Review
 Only one Windows Phone application is Active at any time
 The Start and Back buttons on the phone are used to start new
  applications and return to previously used ones
 If an application is replaced by another it is either made Dormant (still in
  memory but not running) or Tombstoned (removed from memory)
 Applications must use populate methods provided in the App.xaml.cs
  class to save and retrieve state information when appropriate
      State can be stored in memory for quick reload and in isolated
       storage which serve as a permanent store




1
    Windows Phone                                12
2
Background Tasks
Multitasking Capabilities

 Background Agents
    Periodic
    Resource Intensive
 Background Transfer Service
 Alarms and Reminders
 Background Audio




1
    Windows Phone               14
4
Background Agents
   Agents
        Periodic
        Resource Intensive
   An app may have up to one of each
   Initialized in foreground, run in background
        Persisted across reboots
   User control through CPL
        System maximum of 18 periodic agent
   Agent runs for up to 14 days (can be renewed)




1
    Windows Phone
5
Generic Agent Types
Periodic Agents      Resource Intensive
 Occurrence         Agents
   Every 30 min      Occurrence
 Duration              External power
   ~15 seconds         Non-cell network
 Constraints         Duration
   <= 6 MB Memory      10 minutes
   <=10% CPU         Constraints
                        <= 6 MB Memory
1
    Windows Phone
6
Background Agent Functionality

               Allowed              Restricted

     Tiles
     Toast                    Display UI
     Location                 XNA libraries
     Network                  Microphone and Camera
     R/W ISO store            Sensors
     Sockets                  Play audio
                                (may only use background audio APIs)
     Most framework APIs



1
    Windows Phone
7
Demo


Demo1: Captain’s Location Log
Debugging a Background Task
    #if DEBUG_AGENT
     ScheduledActionService.LaunchForTest(taskName,
             TimeSpan.FromSeconds(60));
    #endif


 It would be annoying if we had to wait 30 minutes to get code in the
  agent running so we could debug it
 When we are debugging we can force service to launch itself
 Such code can be conditionally compiled and removed before the
  production version is built




1
     Windows Phone                             19
9
Debugging the Agent Code

   When you use the Back button or Start on the phone to interrupt an
    application with an active Background Task ,Visual Studio does not
    stop running
   It remains attached to the application
   You can then put breakpoints into the background task application and
    debug them as you would any other program
   You can single step, view the contents of variables and even change
    them using the Immediate Window
   This is also true if you are working on a device rather than the emulator
   The same techniques work on ResourceIntensiveAgents



2
    Windows Phone                                20
0
Demo


Demo2: Debugging Tasks
File Transfer Tasks

   It is also possible to create a background task to transfer files to and
    from your application’s isolated storage
   The transfers will continue to work even when the application is not
    running
   An application can monitor the state of the downloads and display their
    status
   Files can be fetched from HTTP or HTTPs hosts
         At the moment FTP is not supported
   The system maintains a queue of active transfers and services each
    one in turn
   Applications can query the state of active transfers

2
    Windows Phone                                22
2
Background Transfer Policies

 There are a set of policies that control transfer behaviour
     Maximum Upload file size: 5Mb
     Maximum Download file size over cellular (mobile phone) data:
      20Mb
     Maximum Download file size over WiFi: 100Mb
 These can be modified by setting the value of TransferPreferences
  on a particular transfer




2
    Windows Phone                          23
3
Transfer Management

 An application can find out how many file transfers it has active
      It will have to do this when it is restarted, as file transfers will
       continue even when the application is not running
 It can then perform transfer management as required
 There is a good example of transfer list management on MSDN:


              http://msdn.microsoft.com/en-us/library/hh202953.aspx




2
    Windows Phone
4
Demo


Demo3: Picture Fetch
Scheduled Notifications

 Time-based, on-phone notifications
 Supports Alerts & Reminders
 Persist across reboots
 Adheres to user settings
 Consistent with phone UX




2
    Windows Phone              26
6
Alarms vs Reminders?
    Alarms                   Remind
                             ers




•   Modal                 • Rich information
•   Snooze and Dismiss    • Integrates with other
•   Sound customization     reminders
•   No app invocation     • Snooze and Dismiss
•   No stacking           • Launch app
                          • Follows the phones global
    27                      settings
Creating a Reminder
    using Microsoft.Phone.Scheduler;
    ...
    eggReminder = new Reminder("Egg Timer");

    eggReminder.BeginTime = DateTime.Now + new TimeSpan(0, eggTime, 0);
    eggReminder.Content = "Egg Ready";
    eggReminder.RecurrenceType = RecurrenceInterval.None;
    eggReminder.NavigationUri = new Uri("/EggReadyPage.xaml",
             UriKind.Relative);

    ScheduledActionService.Add(eggReminder);



 This code creates a reminder and adds it as a scheduled service
 The value eggTime holds the length of the delay
 This code also sets the url of the page in the application


2
     Windows Phone                             28
8
Reminder Housekeeping
    Reminder eggReminder = ScheduledActionService.Find("Egg Timer")
             as Reminder;

    if ( eggReminder != null )
    {
        ScheduledActionService.Remove("Egg Timer");
    }

 Reminders are identified by name
 This code finds the “Egg Timer” reminder and then removes it from the
  scheduler




2
     Windows Phone                           29
9
Demo


Demo4: Egg Timer
Audio Playback Agents
 It is also possible to create
  an Audio Playback Agent
  that will manage an
  application controlled
  playlist
 The mechanism is the
  same as for other
  background tasks
 The audio can be
  streamed or held in the
  application isolated
  storage




3
    Windows Phone                 31
1
Background Audio
 Playback
     App provides URL or stream to Zune
     Audio continues to play even if app is closed
     App is notified of file or buffer near completion
 Phone Integration
     Music & Video Hub
     Universal Volume Control (UVC), lauch app, controls, contextual
      info
     Contextual launch – Start menu, UVC, Music & Video Hub
 App Integration
     App can retrieve playback status, progress, & metadata
     Playback notification registration

3
    Windows Phone                            32
2
Review

 An application can create background processes
      Periodic Task and ResourceIntensive task run when the
       application is stopped
      Scheduled notifications will fire whether the application is running
       or not
      Audio Playback run alongside the application
 Applications and their background processes can communicate via
  isolated storage
 Visual Studio can be used to debug background tasks in the same way
  as foreground applications



3
    Windows Phone                              33
3

More Related Content

Similar to follow-app BOOTCAMP 2: Windows phone fast application switching

Cool Stuff Your App Can Do
Cool Stuff Your App Can DoCool Stuff Your App Can Do
Cool Stuff Your App Can Do
Ed Donahue
 
Windows Phone Fast App Switching, Tombstoning and Multitasking
Windows Phone Fast App Switching, Tombstoning and MultitaskingWindows Phone Fast App Switching, Tombstoning and Multitasking
Windows Phone Fast App Switching, Tombstoning and Multitasking
Microsoft Developer Network (MSDN) - Belgium and Luxembourg
 
Windows Phone and mobile application development
Windows Phone and mobile application developmentWindows Phone and mobile application development
Windows Phone and mobile application development
IT Booze
 
Windows Phone Application Platform
Windows Phone Application PlatformWindows Phone Application Platform
Windows Phone Application Platform
Dave Bost
 
Windows Phone 7.5 Mango - What's New
Windows Phone 7.5 Mango - What's NewWindows Phone 7.5 Mango - What's New
Windows Phone 7.5 Mango - What's New
Sascha Corti
 
Windows 8 Client Part 2 "The Application internals for IT-Pro's"
Windows 8 Client Part 2 "The Application internals for IT-Pro's"  Windows 8 Client Part 2 "The Application internals for IT-Pro's"
Windows 8 Client Part 2 "The Application internals for IT-Pro's"
Microsoft TechNet - Belgium and Luxembourg
 
AISEC 12 april 2012 WP 7.1.1
AISEC 12 april 2012  WP 7.1.1AISEC 12 april 2012  WP 7.1.1
AISEC 12 april 2012 WP 7.1.1
Catalin Gheorghiu
 
07 wp7 application lifecycle
07 wp7   application lifecycle07 wp7   application lifecycle
07 wp7 application lifecycle
Tao Wang
 
Will it run or will it not run? Background processes in Android 6 - Anna Lifs...
Will it run or will it not run? Background processes in Android 6 - Anna Lifs...Will it run or will it not run? Background processes in Android 6 - Anna Lifs...
Will it run or will it not run? Background processes in Android 6 - Anna Lifs...
DroidConTLV
 
Windows Phone Concept - 7.1 & 8 Preview
Windows Phone Concept - 7.1 & 8 PreviewWindows Phone Concept - 7.1 & 8 Preview
Windows Phone Concept - 7.1 & 8 Preview
Pou Mason
 
An end-to-end experience of Windows Phone 7 development (Part 1)
An end-to-end experience of Windows Phone 7 development (Part 1)An end-to-end experience of Windows Phone 7 development (Part 1)
An end-to-end experience of Windows Phone 7 development (Part 1)
rudigrobler
 
Windows 8 BootCamp
Windows 8 BootCampWindows 8 BootCamp
Windows 8 BootCamp
Einar Ingebrigtsen
 
Anatomy of android application
Anatomy of android applicationAnatomy of android application
Anatomy of android application
Nikunj Dhameliya
 
Sinergija 11 WP7 Mango multitasking and “multitasking”
Sinergija 11   WP7 Mango multitasking and “multitasking”Sinergija 11   WP7 Mango multitasking and “multitasking”
Sinergija 11 WP7 Mango multitasking and “multitasking”
Catalin Gheorghiu
 
OPERATING SYSTEM BY DR .MUGABO MG MKAMA
OPERATING SYSTEM BY DR .MUGABO MG MKAMAOPERATING SYSTEM BY DR .MUGABO MG MKAMA
OPERATING SYSTEM BY DR .MUGABO MG MKAMA
Mugabo Mkama
 
Windows phone 8 session 10
Windows phone 8 session 10Windows phone 8 session 10
Windows phone 8 session 10
hitesh chothani
 
Bn0202 operatingsystemsfeaturesandfunctions
Bn0202 operatingsystemsfeaturesandfunctionsBn0202 operatingsystemsfeaturesandfunctions
Bn0202 operatingsystemsfeaturesandfunctions
Panzer944
 
Android os
Android osAndroid os
Android os
AGAM SHAH
 
Windows Phone 8 - 6 Background Agents
Windows Phone 8 - 6 Background AgentsWindows Phone 8 - 6 Background Agents
Windows Phone 8 - 6 Background Agents
Oliver Scheer
 
Android OS
Android OSAndroid OS
Android OS
Vishal Sapariya
 

Similar to follow-app BOOTCAMP 2: Windows phone fast application switching (20)

Cool Stuff Your App Can Do
Cool Stuff Your App Can DoCool Stuff Your App Can Do
Cool Stuff Your App Can Do
 
Windows Phone Fast App Switching, Tombstoning and Multitasking
Windows Phone Fast App Switching, Tombstoning and MultitaskingWindows Phone Fast App Switching, Tombstoning and Multitasking
Windows Phone Fast App Switching, Tombstoning and Multitasking
 
Windows Phone and mobile application development
Windows Phone and mobile application developmentWindows Phone and mobile application development
Windows Phone and mobile application development
 
Windows Phone Application Platform
Windows Phone Application PlatformWindows Phone Application Platform
Windows Phone Application Platform
 
Windows Phone 7.5 Mango - What's New
Windows Phone 7.5 Mango - What's NewWindows Phone 7.5 Mango - What's New
Windows Phone 7.5 Mango - What's New
 
Windows 8 Client Part 2 "The Application internals for IT-Pro's"
Windows 8 Client Part 2 "The Application internals for IT-Pro's"  Windows 8 Client Part 2 "The Application internals for IT-Pro's"
Windows 8 Client Part 2 "The Application internals for IT-Pro's"
 
AISEC 12 april 2012 WP 7.1.1
AISEC 12 april 2012  WP 7.1.1AISEC 12 april 2012  WP 7.1.1
AISEC 12 april 2012 WP 7.1.1
 
07 wp7 application lifecycle
07 wp7   application lifecycle07 wp7   application lifecycle
07 wp7 application lifecycle
 
Will it run or will it not run? Background processes in Android 6 - Anna Lifs...
Will it run or will it not run? Background processes in Android 6 - Anna Lifs...Will it run or will it not run? Background processes in Android 6 - Anna Lifs...
Will it run or will it not run? Background processes in Android 6 - Anna Lifs...
 
Windows Phone Concept - 7.1 & 8 Preview
Windows Phone Concept - 7.1 & 8 PreviewWindows Phone Concept - 7.1 & 8 Preview
Windows Phone Concept - 7.1 & 8 Preview
 
An end-to-end experience of Windows Phone 7 development (Part 1)
An end-to-end experience of Windows Phone 7 development (Part 1)An end-to-end experience of Windows Phone 7 development (Part 1)
An end-to-end experience of Windows Phone 7 development (Part 1)
 
Windows 8 BootCamp
Windows 8 BootCampWindows 8 BootCamp
Windows 8 BootCamp
 
Anatomy of android application
Anatomy of android applicationAnatomy of android application
Anatomy of android application
 
Sinergija 11 WP7 Mango multitasking and “multitasking”
Sinergija 11   WP7 Mango multitasking and “multitasking”Sinergija 11   WP7 Mango multitasking and “multitasking”
Sinergija 11 WP7 Mango multitasking and “multitasking”
 
OPERATING SYSTEM BY DR .MUGABO MG MKAMA
OPERATING SYSTEM BY DR .MUGABO MG MKAMAOPERATING SYSTEM BY DR .MUGABO MG MKAMA
OPERATING SYSTEM BY DR .MUGABO MG MKAMA
 
Windows phone 8 session 10
Windows phone 8 session 10Windows phone 8 session 10
Windows phone 8 session 10
 
Bn0202 operatingsystemsfeaturesandfunctions
Bn0202 operatingsystemsfeaturesandfunctionsBn0202 operatingsystemsfeaturesandfunctions
Bn0202 operatingsystemsfeaturesandfunctions
 
Android os
Android osAndroid os
Android os
 
Windows Phone 8 - 6 Background Agents
Windows Phone 8 - 6 Background AgentsWindows Phone 8 - 6 Background Agents
Windows Phone 8 - 6 Background Agents
 
Android OS
Android OSAndroid OS
Android OS
 

More from QIRIS

[F5 Hit Refresh] Pierpaolo Basile - Accesso alle informazioni con apache lucene
[F5 Hit Refresh] Pierpaolo Basile - Accesso alle informazioni con apache lucene[F5 Hit Refresh] Pierpaolo Basile - Accesso alle informazioni con apache lucene
[F5 Hit Refresh] Pierpaolo Basile - Accesso alle informazioni con apache lucene
QIRIS
 
Francesco Inguscio - Avviare una start-up
Francesco Inguscio - Avviare una start-upFrancesco Inguscio - Avviare una start-up
Francesco Inguscio - Avviare una start-upQIRIS
 
Francesco Inguscio - Start-up financing from the side of the entrepreneur
Francesco Inguscio - Start-up financing from the side of the entrepreneurFrancesco Inguscio - Start-up financing from the side of the entrepreneur
Francesco Inguscio - Start-up financing from the side of the entrepreneurQIRIS
 
Monica Maria Crapanzano - Definire business model e business plan
Monica Maria Crapanzano - Definire business model e business planMonica Maria Crapanzano - Definire business model e business plan
Monica Maria Crapanzano - Definire business model e business planQIRIS
 
Massimo Aliberti - Dal concept al prototipo al prodotto
Massimo Aliberti - Dal concept al prototipo al prodottoMassimo Aliberti - Dal concept al prototipo al prodotto
Massimo Aliberti - Dal concept al prototipo al prodottoQIRIS
 
follow-app DAY 4 - Strumenti per la prototipazione
follow-app DAY 4 - Strumenti per la prototipazionefollow-app DAY 4 - Strumenti per la prototipazione
follow-app DAY 4 - Strumenti per la prototipazioneQIRIS
 
follow-app BOOTCAMP 4: iOS
follow-app BOOTCAMP 4: iOSfollow-app BOOTCAMP 4: iOS
follow-app BOOTCAMP 4: iOSQIRIS
 
follow-app BOOTCAMP 3: Android
follow-app BOOTCAMP 3: Androidfollow-app BOOTCAMP 3: Android
follow-app BOOTCAMP 3: AndroidQIRIS
 
follow-app BOOTCAMP 2: Introduction to silverlight
follow-app BOOTCAMP 2: Introduction to silverlightfollow-app BOOTCAMP 2: Introduction to silverlight
follow-app BOOTCAMP 2: Introduction to silverlight
QIRIS
 
follow-app BOOTCAMP 2: Building windows phone applications with visual studio...
follow-app BOOTCAMP 2: Building windows phone applications with visual studio...follow-app BOOTCAMP 2: Building windows phone applications with visual studio...
follow-app BOOTCAMP 2: Building windows phone applications with visual studio...
QIRIS
 
follow-app BOOTCAMP 2 - Windows Phone: Tiles and Notifications
follow-app BOOTCAMP 2 - Windows Phone: Tiles and Notifications follow-app BOOTCAMP 2 - Windows Phone: Tiles and Notifications
follow-app BOOTCAMP 2 - Windows Phone: Tiles and Notifications
QIRIS
 
follow-app: BOOTCAMP 3 - Introduzione al GTUG
follow-app: BOOTCAMP 3 - Introduzione al GTUGfollow-app: BOOTCAMP 3 - Introduzione al GTUG
follow-app: BOOTCAMP 3 - Introduzione al GTUGQIRIS
 
follow-app DAY 4: Dati, segreti e tecniche per App di successo
follow-app DAY 4: Dati, segreti e tecniche per App di successofollow-app DAY 4: Dati, segreti e tecniche per App di successo
follow-app DAY 4: Dati, segreti e tecniche per App di successoQIRIS
 
follow-ap DAY 4: HTML5 e jQuery
follow-ap DAY 4: HTML5 e jQueryfollow-ap DAY 4: HTML5 e jQuery
follow-ap DAY 4: HTML5 e jQueryQIRIS
 
follow-app DAY 2: Dall'idea al mercato
follow-app DAY 2: Dall'idea al mercatofollow-app DAY 2: Dall'idea al mercato
follow-app DAY 2: Dall'idea al mercato
QIRIS
 
follow-app DAY 2: Dal mercato al business
follow-app DAY 2: Dal mercato al businessfollow-app DAY 2: Dal mercato al business
follow-app DAY 2: Dal mercato al business
QIRIS
 
follow-app DAY 3: Marketing & Sales
follow-app DAY 3: Marketing & Salesfollow-app DAY 3: Marketing & Sales
follow-app DAY 3: Marketing & SalesQIRIS
 
follow-app DAY 2: Risorse utili
follow-app DAY 2: Risorse utilifollow-app DAY 2: Risorse utili
follow-app DAY 2: Risorse utili
QIRIS
 
follow-app DAY 1: Manager e leader
follow-app DAY 1: Manager e leaderfollow-app DAY 1: Manager e leader
follow-app DAY 1: Manager e leader
QIRIS
 
follow-app DAY 1: Facebook IPO
follow-app DAY 1: Facebook IPOfollow-app DAY 1: Facebook IPO
follow-app DAY 1: Facebook IPO
QIRIS
 

More from QIRIS (20)

[F5 Hit Refresh] Pierpaolo Basile - Accesso alle informazioni con apache lucene
[F5 Hit Refresh] Pierpaolo Basile - Accesso alle informazioni con apache lucene[F5 Hit Refresh] Pierpaolo Basile - Accesso alle informazioni con apache lucene
[F5 Hit Refresh] Pierpaolo Basile - Accesso alle informazioni con apache lucene
 
Francesco Inguscio - Avviare una start-up
Francesco Inguscio - Avviare una start-upFrancesco Inguscio - Avviare una start-up
Francesco Inguscio - Avviare una start-up
 
Francesco Inguscio - Start-up financing from the side of the entrepreneur
Francesco Inguscio - Start-up financing from the side of the entrepreneurFrancesco Inguscio - Start-up financing from the side of the entrepreneur
Francesco Inguscio - Start-up financing from the side of the entrepreneur
 
Monica Maria Crapanzano - Definire business model e business plan
Monica Maria Crapanzano - Definire business model e business planMonica Maria Crapanzano - Definire business model e business plan
Monica Maria Crapanzano - Definire business model e business plan
 
Massimo Aliberti - Dal concept al prototipo al prodotto
Massimo Aliberti - Dal concept al prototipo al prodottoMassimo Aliberti - Dal concept al prototipo al prodotto
Massimo Aliberti - Dal concept al prototipo al prodotto
 
follow-app DAY 4 - Strumenti per la prototipazione
follow-app DAY 4 - Strumenti per la prototipazionefollow-app DAY 4 - Strumenti per la prototipazione
follow-app DAY 4 - Strumenti per la prototipazione
 
follow-app BOOTCAMP 4: iOS
follow-app BOOTCAMP 4: iOSfollow-app BOOTCAMP 4: iOS
follow-app BOOTCAMP 4: iOS
 
follow-app BOOTCAMP 3: Android
follow-app BOOTCAMP 3: Androidfollow-app BOOTCAMP 3: Android
follow-app BOOTCAMP 3: Android
 
follow-app BOOTCAMP 2: Introduction to silverlight
follow-app BOOTCAMP 2: Introduction to silverlightfollow-app BOOTCAMP 2: Introduction to silverlight
follow-app BOOTCAMP 2: Introduction to silverlight
 
follow-app BOOTCAMP 2: Building windows phone applications with visual studio...
follow-app BOOTCAMP 2: Building windows phone applications with visual studio...follow-app BOOTCAMP 2: Building windows phone applications with visual studio...
follow-app BOOTCAMP 2: Building windows phone applications with visual studio...
 
follow-app BOOTCAMP 2 - Windows Phone: Tiles and Notifications
follow-app BOOTCAMP 2 - Windows Phone: Tiles and Notifications follow-app BOOTCAMP 2 - Windows Phone: Tiles and Notifications
follow-app BOOTCAMP 2 - Windows Phone: Tiles and Notifications
 
follow-app: BOOTCAMP 3 - Introduzione al GTUG
follow-app: BOOTCAMP 3 - Introduzione al GTUGfollow-app: BOOTCAMP 3 - Introduzione al GTUG
follow-app: BOOTCAMP 3 - Introduzione al GTUG
 
follow-app DAY 4: Dati, segreti e tecniche per App di successo
follow-app DAY 4: Dati, segreti e tecniche per App di successofollow-app DAY 4: Dati, segreti e tecniche per App di successo
follow-app DAY 4: Dati, segreti e tecniche per App di successo
 
follow-ap DAY 4: HTML5 e jQuery
follow-ap DAY 4: HTML5 e jQueryfollow-ap DAY 4: HTML5 e jQuery
follow-ap DAY 4: HTML5 e jQuery
 
follow-app DAY 2: Dall'idea al mercato
follow-app DAY 2: Dall'idea al mercatofollow-app DAY 2: Dall'idea al mercato
follow-app DAY 2: Dall'idea al mercato
 
follow-app DAY 2: Dal mercato al business
follow-app DAY 2: Dal mercato al businessfollow-app DAY 2: Dal mercato al business
follow-app DAY 2: Dal mercato al business
 
follow-app DAY 3: Marketing & Sales
follow-app DAY 3: Marketing & Salesfollow-app DAY 3: Marketing & Sales
follow-app DAY 3: Marketing & Sales
 
follow-app DAY 2: Risorse utili
follow-app DAY 2: Risorse utilifollow-app DAY 2: Risorse utili
follow-app DAY 2: Risorse utili
 
follow-app DAY 1: Manager e leader
follow-app DAY 1: Manager e leaderfollow-app DAY 1: Manager e leader
follow-app DAY 1: Manager e leader
 
follow-app DAY 1: Facebook IPO
follow-app DAY 1: Facebook IPOfollow-app DAY 1: Facebook IPO
follow-app DAY 1: Facebook IPO
 

Recently uploaded

How to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in useHow to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in use
Celine George
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
nitinpv4ai
 
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
Payaamvohra1
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
Iris Thiele Isip-Tan
 
220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx
Kalna College
 
Accounting for Restricted Grants When and How To Record Properly
Accounting for Restricted Grants  When and How To Record ProperlyAccounting for Restricted Grants  When and How To Record Properly
Accounting for Restricted Grants When and How To Record Properly
TechSoup
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
Krassimira Luka
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
deepaannamalai16
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
MJDuyan
 
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptxCapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapitolTechU
 
A Free 200-Page eBook ~ Brain and Mind Exercise.pptx
A Free 200-Page eBook ~ Brain and Mind Exercise.pptxA Free 200-Page eBook ~ Brain and Mind Exercise.pptx
A Free 200-Page eBook ~ Brain and Mind Exercise.pptx
OH TEIK BIN
 
Simple-Present-Tense xxxxxxxxxxxxxxxxxxx
Simple-Present-Tense xxxxxxxxxxxxxxxxxxxSimple-Present-Tense xxxxxxxxxxxxxxxxxxx
Simple-Present-Tense xxxxxxxxxxxxxxxxxxx
RandolphRadicy
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
Steve Thomason
 
Observational Learning
Observational Learning Observational Learning
Observational Learning
sanamushtaq922
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
PsychoTech Services
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
Nguyen Thanh Tu Collection
 
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
ShwetaGawande8
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Henry Hollis
 
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
Kalna College
 
How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17
Celine George
 

Recently uploaded (20)

How to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in useHow to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in use
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
 
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
 
220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx
 
Accounting for Restricted Grants When and How To Record Properly
Accounting for Restricted Grants  When and How To Record ProperlyAccounting for Restricted Grants  When and How To Record Properly
Accounting for Restricted Grants When and How To Record Properly
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
 
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptxCapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
 
A Free 200-Page eBook ~ Brain and Mind Exercise.pptx
A Free 200-Page eBook ~ Brain and Mind Exercise.pptxA Free 200-Page eBook ~ Brain and Mind Exercise.pptx
A Free 200-Page eBook ~ Brain and Mind Exercise.pptx
 
Simple-Present-Tense xxxxxxxxxxxxxxxxxxx
Simple-Present-Tense xxxxxxxxxxxxxxxxxxxSimple-Present-Tense xxxxxxxxxxxxxxxxxxx
Simple-Present-Tense xxxxxxxxxxxxxxxxxxx
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
 
Observational Learning
Observational Learning Observational Learning
Observational Learning
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
 
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
 
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
 
How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17
 

follow-app BOOTCAMP 2: Windows phone fast application switching

  • 2. Topics  The Windows Phone execution model  Application State Management  Fast Application Switching  Dormant programs and Tombstoning  Application Navigation and Application Switching 2 Windows Phone
  • 4. Application Lifecycle - Dormant Fast App Resume running State preserved! e.IsApplicationInstancePreserved Save State! == true activated deactivated dormant Phone resources detached Threads & timers suspended 4 Windows Phone
  • 5. Application Lifecycle - Tombstoned Resuming .. . Restore state! e.IsApplicationInstancePreserved == false running activated deactivated Tombstone the oldest app Tombstoned dormant Phone resources detached Threads & timers suspended 5 Windows Phone
  • 6. Methods & Events 6 Windows Phone 6
  • 7. Finding the Resume type private void Application_Activated(object sender, ActivatedEventArgs e) { if (e.IsApplicationInstancePreserved) { // Dormant - objects in memory intact } else { // Tombstoned - need to reload } }  The Activation handler can test a flag to determine the type of resume taking place 7 Windows Phone
  • 8. Deactivation Resource Management MediaPlayer.Pause MediaElement.Pause SoundEffectInstance.Pause VibrateController.Stop PhotoCamera.Dispose Save page/global state XNA Audio Paused Sensors Notifications suppressed Networking Cancelled Sockets Disconnected MediaElement Disconnected Camera Disposed 8 Windows Phone
  • 9. Activation Resource Management MediaElement.Source/Position/ Play Socket.ConnectAsync new PhotoCamera/VideoCamera Restore app state if tombstoned XNA Audio Resumed Sensors Notifications resumed Networking Completed with Cancellation Sockets - MediaElement - Camera - 9 Windows Phone
  • 10. Isolated Storage vs State Storage  Isolated storage is so called because the data for an application is isolated from all other applications  It can be used as filestore where an application can store folders and files  It is slow to access, since it is based on NVRAM technology  It can also be used to store name/value pairs, e.g. program settings  State storage is so called because it is used to hold the state of an application  It can be used to store name/value pairs which are held in memory for dormant or tombstoned applications  It provides very quick access to data 1 Windows Phone 10 0
  • 11. Captain’s Log Demo • With No Storage • With Storage • Fully Working
  • 12. Fast App Switching and Tombstoning Review  Only one Windows Phone application is Active at any time  The Start and Back buttons on the phone are used to start new applications and return to previously used ones  If an application is replaced by another it is either made Dormant (still in memory but not running) or Tombstoned (removed from memory)  Applications must use populate methods provided in the App.xaml.cs class to save and retrieve state information when appropriate  State can be stored in memory for quick reload and in isolated storage which serve as a permanent store 1 Windows Phone 12 2
  • 14. Multitasking Capabilities  Background Agents  Periodic  Resource Intensive  Background Transfer Service  Alarms and Reminders  Background Audio 1 Windows Phone 14 4
  • 15. Background Agents  Agents  Periodic  Resource Intensive  An app may have up to one of each  Initialized in foreground, run in background  Persisted across reboots  User control through CPL  System maximum of 18 periodic agent  Agent runs for up to 14 days (can be renewed) 1 Windows Phone 5
  • 16. Generic Agent Types Periodic Agents Resource Intensive  Occurrence Agents  Every 30 min  Occurrence  Duration  External power  ~15 seconds  Non-cell network  Constraints  Duration  <= 6 MB Memory  10 minutes  <=10% CPU  Constraints  <= 6 MB Memory 1 Windows Phone 6
  • 17. Background Agent Functionality Allowed Restricted  Tiles  Toast  Display UI  Location  XNA libraries  Network  Microphone and Camera  R/W ISO store  Sensors  Sockets  Play audio (may only use background audio APIs)  Most framework APIs 1 Windows Phone 7
  • 19. Debugging a Background Task #if DEBUG_AGENT ScheduledActionService.LaunchForTest(taskName, TimeSpan.FromSeconds(60)); #endif  It would be annoying if we had to wait 30 minutes to get code in the agent running so we could debug it  When we are debugging we can force service to launch itself  Such code can be conditionally compiled and removed before the production version is built 1 Windows Phone 19 9
  • 20. Debugging the Agent Code  When you use the Back button or Start on the phone to interrupt an application with an active Background Task ,Visual Studio does not stop running  It remains attached to the application  You can then put breakpoints into the background task application and debug them as you would any other program  You can single step, view the contents of variables and even change them using the Immediate Window  This is also true if you are working on a device rather than the emulator  The same techniques work on ResourceIntensiveAgents 2 Windows Phone 20 0
  • 22. File Transfer Tasks  It is also possible to create a background task to transfer files to and from your application’s isolated storage  The transfers will continue to work even when the application is not running  An application can monitor the state of the downloads and display their status  Files can be fetched from HTTP or HTTPs hosts  At the moment FTP is not supported  The system maintains a queue of active transfers and services each one in turn  Applications can query the state of active transfers 2 Windows Phone 22 2
  • 23. Background Transfer Policies  There are a set of policies that control transfer behaviour  Maximum Upload file size: 5Mb  Maximum Download file size over cellular (mobile phone) data: 20Mb  Maximum Download file size over WiFi: 100Mb  These can be modified by setting the value of TransferPreferences on a particular transfer 2 Windows Phone 23 3
  • 24. Transfer Management  An application can find out how many file transfers it has active  It will have to do this when it is restarted, as file transfers will continue even when the application is not running  It can then perform transfer management as required  There is a good example of transfer list management on MSDN: http://msdn.microsoft.com/en-us/library/hh202953.aspx 2 Windows Phone 4
  • 26. Scheduled Notifications  Time-based, on-phone notifications  Supports Alerts & Reminders  Persist across reboots  Adheres to user settings  Consistent with phone UX 2 Windows Phone 26 6
  • 27. Alarms vs Reminders? Alarms Remind ers • Modal • Rich information • Snooze and Dismiss • Integrates with other • Sound customization reminders • No app invocation • Snooze and Dismiss • No stacking • Launch app • Follows the phones global 27 settings
  • 28. Creating a Reminder using Microsoft.Phone.Scheduler; ... eggReminder = new Reminder("Egg Timer"); eggReminder.BeginTime = DateTime.Now + new TimeSpan(0, eggTime, 0); eggReminder.Content = "Egg Ready"; eggReminder.RecurrenceType = RecurrenceInterval.None; eggReminder.NavigationUri = new Uri("/EggReadyPage.xaml", UriKind.Relative); ScheduledActionService.Add(eggReminder);  This code creates a reminder and adds it as a scheduled service  The value eggTime holds the length of the delay  This code also sets the url of the page in the application 2 Windows Phone 28 8
  • 29. Reminder Housekeeping Reminder eggReminder = ScheduledActionService.Find("Egg Timer") as Reminder; if ( eggReminder != null ) { ScheduledActionService.Remove("Egg Timer"); }  Reminders are identified by name  This code finds the “Egg Timer” reminder and then removes it from the scheduler 2 Windows Phone 29 9
  • 31. Audio Playback Agents  It is also possible to create an Audio Playback Agent that will manage an application controlled playlist  The mechanism is the same as for other background tasks  The audio can be streamed or held in the application isolated storage 3 Windows Phone 31 1
  • 32. Background Audio  Playback  App provides URL or stream to Zune  Audio continues to play even if app is closed  App is notified of file or buffer near completion  Phone Integration  Music & Video Hub  Universal Volume Control (UVC), lauch app, controls, contextual info  Contextual launch – Start menu, UVC, Music & Video Hub  App Integration  App can retrieve playback status, progress, & metadata  Playback notification registration 3 Windows Phone 32 2
  • 33. Review  An application can create background processes  Periodic Task and ResourceIntensive task run when the application is stopped  Scheduled notifications will fire whether the application is running or not  Audio Playback run alongside the application  Applications and their background processes can communicate via isolated storage  Visual Studio can be used to debug background tasks in the same way as foreground applications 3 Windows Phone 33 3