Windows Phone: multitasking and local database
-
Upload
radu-vunvulea -
Category
Technology
-
view
1.249 -
download
2
Transcript of Windows Phone: multitasking and local database
Multitasking and Local Dababase in
Windows Phone Mango
Radu Vunvulea
Windows Phone MangoMultitasking
Multitasking
Resource Management
Built-in services 3rd-party services
Alarms & Reminders
File Transfers
Background Audio
Periodic Execution
Fast App Switching
Multitasking and Phone Health
Monitor resource usage
Align with system and user activity
Balance foreground and background
Processing on demand
New OS services
Application Lifecycle
Save state but do not discard it
Reload / refresh state only if needed
Application is resident in memory; system detaches resources and pauses threads
Tombstoned
DeactivatedDormant
RunningActivated
Deactivated
RunningActivated
Save state but do not discard it
Reload / refresh state only if needed
Application is resident in memory; system detaches resources and pauses threads
Tombstoned
Dormant
Application Lifecycle
Background transfer
20 MB 20 MB
100 MB
Unlimited
End-to-End Architecture
System Services
ISO StoreCloud
LogicUX
MyApp.dll
Application OS
Logic
MyAppAgent.dll
Single App
DeveloperMyApp Solution
MyApp Project
MyAppAgent Project
WMAppManifest
Demo
Background Agents
Ce ne este permis:• Base API• Update de tile• Toasts• Location• Networking• Storage
Ce nu ne este permis:• Librarii XNA• Audio• Senzori• Microfon• Camera• UI
Differences Between Agents
Periodic Agent• Runs every 30 minutes
• Any network connection
• Runs for 25 seconds
• Used for location, data sync,
etc.
Resource-Intensive Agent• Runs on external power
• Non-cell network
connection
• Runs for 10 mins, recurring
• Used for daily tasks, large
data syncs, etc.
Windows Phone MangoLocal Database
Where is database stored
Application
Data Context(Sistem.Data.Linq)
IsolatedStorage
LocalDatabase
LINQ to SQL Runtime
Good to know
• Isolated Storage is used to store database files
• LINQ to SQL is used as the ORM engine
• LINQ is used to query data
• Only System.Data.Linq assembly must be added to the project.
Database design
• Custom connection string format: "Data Source='isostore:/MyDir/DbName.sdf'"
• T-SQL queries are not supported
• The code-first approach to defining the database schema is preferred in this version of Windows Phone 7.1 Mango.
Data Source='isostore:/MyDir/DbName.sdf'
Limitations
• ADO.NET Objects are not supported• Skip() and Take() require an ordered list and
constants values• Only Microsoft SQL CE data types are
supported• BinaryFormatter is not supported by default
(hack: CustomType and implement ToString() and Parse() in your custom class)
• ExecuteCommand is not suported – NO T-SQL, NO DML statement, NO DDL
Process to follow to use SQL CE
Implement all database classes: tables, columns,
relations, datacontext, etc
Create a new database (.sdf) file in Isolated Storage(by
default the database is empty)
Populate the database stored in
the Isolated Storage with data
Code Sample
?Questions