SlideShare una empresa de Scribd logo
1 de 25
WinRT Apps
24/04/2014
Our objective is to provide innovation
to society.
We work to shape trends and ideas using
technology.
How do we think• Software Development Engineer - Apps @ BR
Soluções Integradas
• Microsoft Most Valuable Professional (MVP) C#
• Microsoft Certified Professional
• Microsoft Certified Application Developer
• Microsoft Certified Solution Developer
• Microsoft Certified Technology Specialist - Silverlight
• Ex Moderador do Fórum de Silverlight da MSDN Brasil
• São Paulino
• Viciado em games
• Nerd e Bonitão
Ricardo Dorta
http://ricardodorta.net.br
@dortaway
http://ricardodorta.net.br
@dortaway
http://ricardodorta.net.br
@dortaway
NotRunning Running
http://ricardodorta.net.br
@dortaway
sealed partial class App : Application
{
/// <summary>
/// Invoked when the application is launched normally by the end user.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
protected override async void OnLaunched(LaunchActivatedEventArgs e)
{
// How did the app exit the last time it was run (if at all)
ApplicationExecutionState previousState = e.PreviousExecutionState;
// What kind of launch is this?
ActivationKind activationKind = e.Kind;
// ...
NotRunning
Running
Suspended
Terminated
ClosedByUser
Launch
File
Protocol
VoiceCommand
Etc.
Aplicativo entra em modo
“suspended”
Todo o código do aplicativo para
de rodar
Nenhum timer executa o “tick”
Nenhum evento é disparado
O processo ainda está ativo na
memória
O código tem uma “chance” de
ser executado(próximo slide)
http://ricardodorta.net.br
@dortaway
sealed partial class App : Application
{
public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
}
private async void OnSuspending(object sender, SuspendingEventArgs e)
{
// Ask for a deferral if you need to do async work
var deferral = e.SuspendingOperation.GetDeferral();
// TODO: whatever async work you need to do when suspending
deferral.Complete(); // Then mark the deferral complete
}
O mesmo aplicativo vai
para o estado “resumed”
Mesmo processo, mesmos
valores de memória,
portanto os valores de suas
varíaveis estão intactas!
Todo o seu código volta a
rodar
Seu código tem uma
chance de responder...
Launch Back Switcher
sealed partial class App : Application
{
public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
this.Resuming += OnResuming;
}
private void OnResuming(object sender, object e)
{
// TODO: whatever you need to do to resume your app
}
http://ricardodorta.net.br
@dortaway
http://ricardodorta.net.br
@dortaway
http://bit.ly/w8Resuming
Running
http://ricardodorta.net.br
@dortaway
Terminated
Diretório App Data Local
(ou diretório para dados roaming)
12:38
12:38
Jim Jones
Tel: 0111 222 333
Bob Brown
Tel: 0444 555 666
Arthur Abbott
Tel: 0777 888 999
CONTACTS
all 12:38
12:38
Work
Tel: 0111 222 333
Home
Tel: 0444 555 666
Email
jim@jones.com
CONTACTS
Jim Jones
12:38
CONTACTS
Add Phone
Mobile Phone
Phone type
Phone number
0888 777
State
Data
http://ricardodorta.net.br
@dortaway
http://aka.ms/Tsatr4

Más contenido relacionado

Destacado

Visual Studio Summit 2016 - Mobile Wars - Nativo X Hibrido
Visual Studio Summit 2016 - Mobile Wars - Nativo X HibridoVisual Studio Summit 2016 - Mobile Wars - Nativo X Hibrido
Visual Studio Summit 2016 - Mobile Wars - Nativo X HibridoRicardo Dorta
 
Soluções escaláveis com Microsoft Orleans e Windows Azure
Soluções escaláveis com Microsoft Orleans e Windows AzureSoluções escaláveis com Microsoft Orleans e Windows Azure
Soluções escaláveis com Microsoft Orleans e Windows AzureVinicius Quaiato
 
Reaproveitamento de código com Xamarin e MVVM Cross
Reaproveitamento de código com Xamarin e MVVM CrossReaproveitamento de código com Xamarin e MVVM Cross
Reaproveitamento de código com Xamarin e MVVM CrossRicardo Dorta
 
Arquitetura de Software e o Arquiteto - Secomp Londrina - Vinicius Quaiato
Arquitetura de Software e o Arquiteto - Secomp Londrina - Vinicius QuaiatoArquitetura de Software e o Arquiteto - Secomp Londrina - Vinicius Quaiato
Arquitetura de Software e o Arquiteto - Secomp Londrina - Vinicius QuaiatoVinicius Quaiato
 

Destacado (7)

Visual Studio Summit 2016 - Mobile Wars - Nativo X Hibrido
Visual Studio Summit 2016 - Mobile Wars - Nativo X HibridoVisual Studio Summit 2016 - Mobile Wars - Nativo X Hibrido
Visual Studio Summit 2016 - Mobile Wars - Nativo X Hibrido
 
Soluções escaláveis com Microsoft Orleans e Windows Azure
Soluções escaláveis com Microsoft Orleans e Windows AzureSoluções escaláveis com Microsoft Orleans e Windows Azure
Soluções escaláveis com Microsoft Orleans e Windows Azure
 
Functional programming
Functional programmingFunctional programming
Functional programming
 
Reaproveitamento de código com Xamarin e MVVM Cross
Reaproveitamento de código com Xamarin e MVVM CrossReaproveitamento de código com Xamarin e MVVM Cross
Reaproveitamento de código com Xamarin e MVVM Cross
 
Azure WebJobs
Azure WebJobsAzure WebJobs
Azure WebJobs
 
IdentityServer 4
IdentityServer 4IdentityServer 4
IdentityServer 4
 
Arquitetura de Software e o Arquiteto - Secomp Londrina - Vinicius Quaiato
Arquitetura de Software e o Arquiteto - Secomp Londrina - Vinicius QuaiatoArquitetura de Software e o Arquiteto - Secomp Londrina - Vinicius Quaiato
Arquitetura de Software e o Arquiteto - Secomp Londrina - Vinicius Quaiato
 

Similar a Ciclo de Vida de Aplicativos Windows - The Developers Conferece 2014

2018 (codeone) Graal VM and MicroProfile a polyglot microservices solution [d...
2018 (codeone) Graal VM and MicroProfile a polyglot microservices solution [d...2018 (codeone) Graal VM and MicroProfile a polyglot microservices solution [d...
2018 (codeone) Graal VM and MicroProfile a polyglot microservices solution [d...César Hernández
 
GraalVM and MicroProfile - A Polyglot Microservices Solution
GraalVM and MicroProfile - A Polyglot Microservices SolutionGraalVM and MicroProfile - A Polyglot Microservices Solution
GraalVM and MicroProfile - A Polyglot Microservices SolutionRoberto Cortez
 
Easy logins for Ruby web applications
Easy logins for Ruby web applicationsEasy logins for Ruby web applications
Easy logins for Ruby web applicationsFrancois Marier
 
What Web Developers Need to Know to Develop Windows 8 Apps
What Web Developers Need to Know to Develop Windows 8 AppsWhat Web Developers Need to Know to Develop Windows 8 Apps
What Web Developers Need to Know to Develop Windows 8 AppsDoris Chen
 
Introduction to Titanium and how to connect with a PHP backend
Introduction to Titanium and how to connect with a PHP backendIntroduction to Titanium and how to connect with a PHP backend
Introduction to Titanium and how to connect with a PHP backendJoseluis Laso
 
Built to last javascript for enterprise
Built to last   javascript for enterpriseBuilt to last   javascript for enterprise
Built to last javascript for enterpriseMarjan Nikolovski
 
All a flutter about Flutter.io
All a flutter about Flutter.ioAll a flutter about Flutter.io
All a flutter about Flutter.ioSteven Cooper
 
Easy logins for JavaScript web applications
Easy logins for JavaScript web applicationsEasy logins for JavaScript web applications
Easy logins for JavaScript web applicationsFrancois Marier
 
sMash at May NYPHP UG
sMash at May NYPHP UGsMash at May NYPHP UG
sMash at May NYPHP UGProject Zero
 
Enterprise JavaScript ... what the heck?
Enterprise JavaScript ... what the heck?Enterprise JavaScript ... what the heck?
Enterprise JavaScript ... what the heck?Nedelcho Delchev
 
Core data intermediate Workshop at NSSpain 2013
Core data intermediate Workshop at NSSpain 2013Core data intermediate Workshop at NSSpain 2013
Core data intermediate Workshop at NSSpain 2013Diego Freniche Brito
 
Node.js: CAMTA Presentation
Node.js: CAMTA PresentationNode.js: CAMTA Presentation
Node.js: CAMTA PresentationRob Tweed
 
From Idea to App (or “How we roll at Small Town Heroes”)
From Idea to App (or “How we roll at Small Town Heroes”)From Idea to App (or “How we roll at Small Town Heroes”)
From Idea to App (or “How we roll at Small Town Heroes”)Bramus Van Damme
 
[UniteKorea2013] Protecting your Android content
[UniteKorea2013] Protecting your Android content[UniteKorea2013] Protecting your Android content
[UniteKorea2013] Protecting your Android contentWilliam Hugo Yang
 
Building Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in RailsBuilding Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in RailsJim Jeffers
 
2020-02-20 - HashiCorpUserGroup Madring - Integrating HashiCorp Vault and Kub...
2020-02-20 - HashiCorpUserGroup Madring - Integrating HashiCorp Vault and Kub...2020-02-20 - HashiCorpUserGroup Madring - Integrating HashiCorp Vault and Kub...
2020-02-20 - HashiCorpUserGroup Madring - Integrating HashiCorp Vault and Kub...Andrey Devyatkin
 
Introduction to Software Development
Introduction to Software DevelopmentIntroduction to Software Development
Introduction to Software DevelopmentZeeshan MIrza
 
OWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript ApplicationsOWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript ApplicationsLewis Ardern
 

Similar a Ciclo de Vida de Aplicativos Windows - The Developers Conferece 2014 (20)

2018 (codeone) Graal VM and MicroProfile a polyglot microservices solution [d...
2018 (codeone) Graal VM and MicroProfile a polyglot microservices solution [d...2018 (codeone) Graal VM and MicroProfile a polyglot microservices solution [d...
2018 (codeone) Graal VM and MicroProfile a polyglot microservices solution [d...
 
GraalVM and MicroProfile - A Polyglot Microservices Solution
GraalVM and MicroProfile - A Polyglot Microservices SolutionGraalVM and MicroProfile - A Polyglot Microservices Solution
GraalVM and MicroProfile - A Polyglot Microservices Solution
 
Easy logins for Ruby web applications
Easy logins for Ruby web applicationsEasy logins for Ruby web applications
Easy logins for Ruby web applications
 
What Web Developers Need to Know to Develop Windows 8 Apps
What Web Developers Need to Know to Develop Windows 8 AppsWhat Web Developers Need to Know to Develop Windows 8 Apps
What Web Developers Need to Know to Develop Windows 8 Apps
 
Introduction to Titanium and how to connect with a PHP backend
Introduction to Titanium and how to connect with a PHP backendIntroduction to Titanium and how to connect with a PHP backend
Introduction to Titanium and how to connect with a PHP backend
 
Built to last javascript for enterprise
Built to last   javascript for enterpriseBuilt to last   javascript for enterprise
Built to last javascript for enterprise
 
All a flutter about Flutter.io
All a flutter about Flutter.ioAll a flutter about Flutter.io
All a flutter about Flutter.io
 
Easy logins for JavaScript web applications
Easy logins for JavaScript web applicationsEasy logins for JavaScript web applications
Easy logins for JavaScript web applications
 
sMash at May NYPHP UG
sMash at May NYPHP UGsMash at May NYPHP UG
sMash at May NYPHP UG
 
Enterprise JavaScript ... what the heck?
Enterprise JavaScript ... what the heck?Enterprise JavaScript ... what the heck?
Enterprise JavaScript ... what the heck?
 
Core data intermediate Workshop at NSSpain 2013
Core data intermediate Workshop at NSSpain 2013Core data intermediate Workshop at NSSpain 2013
Core data intermediate Workshop at NSSpain 2013
 
Node.js: CAMTA Presentation
Node.js: CAMTA PresentationNode.js: CAMTA Presentation
Node.js: CAMTA Presentation
 
Deployment talk dpc 13
Deployment talk dpc 13Deployment talk dpc 13
Deployment talk dpc 13
 
From Idea to App (or “How we roll at Small Town Heroes”)
From Idea to App (or “How we roll at Small Town Heroes”)From Idea to App (or “How we roll at Small Town Heroes”)
From Idea to App (or “How we roll at Small Town Heroes”)
 
[UniteKorea2013] Protecting your Android content
[UniteKorea2013] Protecting your Android content[UniteKorea2013] Protecting your Android content
[UniteKorea2013] Protecting your Android content
 
Automating android
Automating androidAutomating android
Automating android
 
Building Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in RailsBuilding Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in Rails
 
2020-02-20 - HashiCorpUserGroup Madring - Integrating HashiCorp Vault and Kub...
2020-02-20 - HashiCorpUserGroup Madring - Integrating HashiCorp Vault and Kub...2020-02-20 - HashiCorpUserGroup Madring - Integrating HashiCorp Vault and Kub...
2020-02-20 - HashiCorpUserGroup Madring - Integrating HashiCorp Vault and Kub...
 
Introduction to Software Development
Introduction to Software DevelopmentIntroduction to Software Development
Introduction to Software Development
 
OWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript ApplicationsOWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript Applications
 

Último

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 

Último (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

Ciclo de Vida de Aplicativos Windows - The Developers Conferece 2014

  • 2. Our objective is to provide innovation to society. We work to shape trends and ideas using technology. How do we think• Software Development Engineer - Apps @ BR Soluções Integradas • Microsoft Most Valuable Professional (MVP) C# • Microsoft Certified Professional • Microsoft Certified Application Developer • Microsoft Certified Solution Developer • Microsoft Certified Technology Specialist - Silverlight • Ex Moderador do Fórum de Silverlight da MSDN Brasil • São Paulino • Viciado em games • Nerd e Bonitão Ricardo Dorta http://ricardodorta.net.br @dortaway
  • 4.
  • 5.
  • 8. sealed partial class App : Application { /// <summary> /// Invoked when the application is launched normally by the end user. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs e) { // How did the app exit the last time it was run (if at all) ApplicationExecutionState previousState = e.PreviousExecutionState; // What kind of launch is this? ActivationKind activationKind = e.Kind; // ... NotRunning Running Suspended Terminated ClosedByUser Launch File Protocol VoiceCommand Etc.
  • 9. Aplicativo entra em modo “suspended” Todo o código do aplicativo para de rodar Nenhum timer executa o “tick” Nenhum evento é disparado O processo ainda está ativo na memória O código tem uma “chance” de ser executado(próximo slide) http://ricardodorta.net.br @dortaway
  • 10. sealed partial class App : Application { public App() { this.InitializeComponent(); this.Suspending += OnSuspending; } private async void OnSuspending(object sender, SuspendingEventArgs e) { // Ask for a deferral if you need to do async work var deferral = e.SuspendingOperation.GetDeferral(); // TODO: whatever async work you need to do when suspending deferral.Complete(); // Then mark the deferral complete }
  • 11. O mesmo aplicativo vai para o estado “resumed” Mesmo processo, mesmos valores de memória, portanto os valores de suas varíaveis estão intactas! Todo o seu código volta a rodar Seu código tem uma chance de responder... Launch Back Switcher
  • 12. sealed partial class App : Application { public App() { this.InitializeComponent(); this.Suspending += OnSuspending; this.Resuming += OnResuming; } private void OnResuming(object sender, object e) { // TODO: whatever you need to do to resume your app } http://ricardodorta.net.br @dortaway
  • 17.
  • 19.
  • 20.
  • 21.
  • 22. Diretório App Data Local (ou diretório para dados roaming) 12:38 12:38 Jim Jones Tel: 0111 222 333 Bob Brown Tel: 0444 555 666 Arthur Abbott Tel: 0777 888 999 CONTACTS all 12:38 12:38 Work Tel: 0111 222 333 Home Tel: 0444 555 666 Email jim@jones.com CONTACTS Jim Jones 12:38 CONTACTS Add Phone Mobile Phone Phone type Phone number 0888 777 State Data
  • 23.

Notas del editor

  1. The Windows 8.1 model is arguably simpler than the Windows Phone 8.0 model. In Windows 8.1 the whole model is based around the idea that the app is run and then while running it might be suspended/resumed so any temporal state needs to be saved across those boundaries and restored. But...suspended might be followed by terminated if the OS feels like it. In that case, when the app is next launched it will be run with a “Hey, you were previously terminated” flag which the app CAN use to restore any volatile state that was saved at the time of suspension. That’s pretty much it. The Windows Phone 8.0 model is more complex in my view although it achieves the same thing. Some notes; The Windows Phone 8.0 has a “Closing” event for when the user does a “back” out of the top level of the application. A developer could use this to store their permanent data changes (not their volatile state). By default, when a user runs a Windows Phone 8.0 app that is already launched, the old app is thrown away and a brand new copy of the app is launched. A user on Windows Phone 8.0 can make an application dormant at any time and the app gets activated/deactivated events much like suspend/resume of Windows 8.1. A dormant app is (to me) the same as a Windows 8.1 suspended app because it is still in memory but it’s consuming zero CPU. Windows Phone 8.0 can make a dormant app into a tombstoned app by killing its process in response to resource pressure. This is similar to Windows 8.1 terminating an app except on Windows Phone 8.0 the OS itself actually takes on the responsibility of storing away both the navigation stack for the app and the volatile state dictionaries that the app has populated (global and per page). This is not done by the OS on Windows 8.1 and possibly that’s because not every app on Windows 8.1 has a Frame at all (including e.g. an HTML/JavaScript) app.
  2. The user finds some way of launching your app. The easiest way is for them to tap on your app’s tile whether it’s on the start screen or not. Other ways of launching an application; From a secondary tile. From a file association. From a protocol association (i.e. mycustomprotocol:// ) From one of the built-in experiences like photos and so on. The calculator is only being used as an example here.
  3. In the first instance, your App object gets created and its OnLaunched override gets called. That override is passed a bunch of information including the previous executation state of your app which would be “NotRunning” the first time around. It also gets passed the “kind” of activation – i.e. Why has your OnLaunched override been called. Is it a straight launch? Was it in response to handling a protocol? Was it to handle a file? Etc. NotRunning – user first runs app after installing from store or rebooting the phone. i.e. they have not already run the app in this “session”. ClosedByUser – user runs the app having previously run it and explicitly closed it down from the task switcher. Terminated – last time the app ran, the system terminated it. Running – the app’s still running and the user is running it again from (e.g.) a secondary tile – not sure whether this is ever possible on the phone or not. Suspended – the app has run, used moved away from it, still suspended in memory and the user runs it again from (e.g.) a secondary tile.
  4. As soon as a user leaves a Windows Phone app, its suspending event fires. On Windows 8.1, an app has 5 seconds to complete processing in the OnSuspending event handler, although certification requires 2 seconds. It is similar on Windows Phone, but general guidance here is to make sure your suspension processing completes as quickly as possible, otherwise you will start to damage the user experience if it’s not written to be as quick as possible. Be careful when using the SupensionManager helper class, as that serializes all data that has been stored through it at this time, which has an impact on Suspension processing time.
  5. It’s important to note here that the usual scenario is that the same app process will be resumed. This is different from what happens on the phone today unless a developer has opted in to “Fast Application Resume” which is an unusual thing for a Windows Phone 8 app to do.
  6. If you have code to execute when the app is resuming, you must wire up an event handler for the App.Resuming event, as shown here.
  7. Be careful! Because the debugger is attached to your code when running under debug, your app *will not* suspend when it loses focus, unlike when running normally. For this reason, the Debug Location Toolbar (normally visible when debugging) displays options for suspending, resuming and ‘suspend and shutdown’ (i.e. terminating) your app. Note that this differs from debugging a Windows Phone Silverlight app which deactivates when your app loses focus, even when running under the debugger.
  8. There’s only one way that a user can close your app – by pressing and holding the Back key to launch the Task Switcher and then tapping the ‘X’ shown on the app screen snapshot. The app will get its suspending event so it will have saved state. The next time the app runs it can use this state to “be aware” that the last time it ran it was explicitly closed by the user. The app then has to decide whether to start from a “clean state” or whether to put the user back to where they were at the last time that they used the app. The guidance is that “each app is different” and it’s up to the app to decide whether to put the user back where they were previously or to start a clean run of the app. If the app is going to attempt to put the user back to where they were previously then it’s almost certainly going to want to factor in the amount of time that has elapsed and what the user was doing at the point where they closed the app.
  9. Demo 1. Simple demo of how an app with a temporal nature doesn’t survive suspend/resume. Described in the document alongside the slide-deck.
  10. If the system becomes short of memory, an app is selected for termination based on internal algorithms based on how long ago the app was running, and the amount of memory that will be freed by terminating it.
  11. If an app is removed from the task switcher and no longer shown there (without being closed by the user) then it has been terminated by the OS. Unlike Windows 8.1, the task switcher shows only running apps. Task switcher will not show an entry for an app that the system has terminated – the user would get back to that terminated app. [Review this]
  12. When thinking about how to restart an app that has been terminated, you (the developer) must consider what the users’ expectations will be. They will be unaware that the system has chosen to terminate their app, so their normal expectation will usually be that the app should pick up from where it left off the last time they used it – unless the state the app should present to a user will have other factors that will affect it, such as ‘were they engaged in an activity that having been interrupted, the reasonable expectation might be to back out of that activity and resume at some earlier state’ or ‘has so much time elapsed that really the app should restart as if launched anew’?
  13. Examples of what ‘recent activity’ might mean; User is timing their workout session with a stopwatch. Stopwatch is ticking down from 60 minutes. User expects that if the app is terminated at minute 32 then when they resume at minute 48 the timer is preserved. User is level 3 deep in a hierarchy of their photos. They move away to browse the app. They return to the app. They expect to be back on their previous photo. User is navigating through a 3 page Wizard to register their sale on an auction web site. They have typed in lots of data that they have not yet submitted. They revisit the app 2 days later and do not expect to have to enter that data again. User has entered some text into a textbox and has made a selection in a combo box. They navigate to another app momentarily and do not expect to have to re-enter those values when they return to the original app.
  14. This slide builds (a lot). The idea here is that the user runs the app, it loads some contacts from some permanent state and then the user taps on one which causes navigation and then they tap on some ‘add’ button to add a new phone number and they enter the type of the phone number and part of the number itself but they have not hit save. The slide highlights in blue that the contact details are coming from permanent data (whether loaded once or loaded on a per page basis) but that the volatile state includes the navigation stack (including parameters) and the current values on the “Phone Type” and “Phone Number” fields on the 3rd page.
  15. The application developer has quite a lot to think about when saving and restoring state: navigation history, navigation arguments and volatile state data. The SuspensionManager and NavigationHelper classes are designed to help with these tasks. See the comments in these classes for information on how to use them correctly.
  16. This is a 2 slide build. App runs up, creates Frame, registers with Suspension Manager which has a slot for Global State and now knows about this frame. Frame then navigates to Page 1 (possibly with a parameter) which means it has a little navigation history and the page creates a navigation helper. User then navigates to Page 2. The navigation helper fires its SaveState event into Page 1 which populates a dictionary which the Navigation Helper saves back to the Suspension Manager as the state for Page 1. Page 2 is created with its own NavigationHelper and our navigation history is now a little longer. The user now moves back to the start screen and so the OS suspends the app which fires the Suspending event which is handled by calling SuspensionManager.SaveAsync(). Next slide…
  17. SaveAsync() calls into its registered frames asking them to save state. So…we grab the navigation state of the Frame in question but it also asks its Page and (via which) the corresponding NavigationHelper to do the right thing which fires the SaveState event which writes the state back into a new “Page 2” dictionary back in the Suspension Manager. The manager can now grab the global dictionary, the page 1 dictionary, the page 2 dictionary, the navigation state (including parameters) and serialize them all to disk using the DataContractSerializer to do its work. Seems over-engineered to me but that’s how it works as far as I understand it.
  18. Demo 3 – haven’t done this one yet.