Windows 8 BootCamp

734 views

Published on

A presentation I gave for Microsoft Partners, 19th of September 2012

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
734
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Visual Studio : Code editor w/ IntellisenseUI Designer DebuggersSimulator Platform window Blend : Code editor WYSIGYG designer Animation Better properties window SimulatorPlatform window
  • Metro App = one foreground full screen window that allows the user to work more efficientlyThe other Metro Apps are quickly suspended to preserve battery lifeAs a developer, you have to know how Windows manages your App lifetime and how to be a good citizenApps are suspended 5 seconds after leaving foreground.However, you get 10 seconds instead when you switch from one App to another.You can check it if you launch an App in Snap view and keep the Task Manager in the Filled view (I’m not able to find a workflow that ends up to the 5 seconds…)
  • Metro App = one foreground full screen window that allows the user to work more efficientlyThe other Metro Apps are quickly suspended to preserve battery lifeAs a developer, you have to know how Windows manages your App lifetime and how to be a good citizenApps are suspended 5 seconds after leaving foreground.However, you get 10 seconds instead when you switch from one App to another.You can check it if you launch an App in Snap view and keep the Task Manager in the Filled view (I’m not able to find a workflow that ends up to the 5 seconds…)
  • Metro App = one foreground full screen window that allows the user to work more efficientlyThe other Metro Apps are quickly suspended to preserve battery lifeAs a developer, you have to know how Windows manages your App lifetime and how to be a good citizenApps are suspended 5 seconds after leaving foreground.However, you get 10 seconds instead when you switch from one App to another.You can check it if you launch an App in Snap view and keep the Task Manager in the Filled view (I’m not able to find a workflow that ends up to the 5 seconds…)
  • = “tombstoning” in Windows phone (read http://msdn.microsoft.com/en-us/library/ff817008(v=vs.92).aspx for the execution model in WP)This also visible with SysInternals Process Explorer (http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx) where you see the same “Suspended” in the CPU column. It was possible to “suspend” a process in Windows 7 with Process Explorer: this is now done by Windows itself for Metro Apps.NOTE: Process Explorer is fully aware of Metro Apps = “Immersive” has new blue color. See Options | Configure Colors | Immersive Process + see package in tooltipWhen you right-click | Resume on a Suspended Metro App, it gets back automatically Suspending immediately by Windows
  • The user can still decide to explicitly “close”/”end” an App by using ALT+F4 or the following touch gesture = “drag the top of the App and drag it down to the bottom of the screen”: in that case, the App gets the suspend notification after 5 secondsThe system is also allowed to “terminate” the apps.. [users can do it too via task manager or Process Explorer]There is no event fired during termination… you should save all your stuff by “suspending” or even better, along the user navigation in the AppDEMO: use Testlimit64 –d 1024 to consume as much memory (working set) as possible and see that first the Metro App working set are trimmed and then some Apps get terminated (download the tool from http://technet.microsoft.com/en-us/sysinternals/bb963901.aspx)Watch http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/WCL405 for Mark Russinovich talk about Windows memory management + demos of Testlimit
  • Splashscreen and background colors are set in the App manifest.It’s used by Windows to display the first screen before the App code starts to runSame during activation through Contracts
  • Splashscreen and background colors are set in the App manifest.It’s used by Windows to display the first screen before the App code starts to runSame during activation through Contracts
  • Ex: update cache on a regular basis such as for weekly TV programs
  • You can control when the background task runs, even after it is triggered, by adding a condition. Once triggered, a background task will not run until all of its conditions are met. The following conditions (represented by the SystemConditionType enumeration) can be used.For instance : InternetAvailable, InternetNotAvailable,SessionConnected, SessionDisconnected, UserNotPresent, UserPresentControl Channel : Background Tasks can keep a connection alive– ControlChannelTriggerTimer : Background tasks can run as frequently as every 15 minutesPush Notification : Background tasks respond to PushNotificationTrigger to receive raw push notifications
  • Resources for background tasks are throttled to make sure the background task is not consuming too much battery (both CPU time and network bandwidth)The throtting is tough for us (humans) to measure because it is CPU time.. When CPU is idle (e.g. making a network call) that does not count against you.. The way the metering happens is that you are allowed a quota within a period and as long as you do not exceed it, you are OK.. Once you exceed it, the system flat out ignores the triggers until the right amount of time has passed  so you can’t assume that you’ll be timely called if you exceed your limit-- Network resource constraints are a function of the amount of energy used by the network interface, which is modeled as the amount of time the network is used to transfer bytes (for download or upload); it is not based on any throughput metrics. The throughput and energy usage of a network interface varies based on factors like link capacity, physical position of the device, or the current load on the WiFi network. WiFi networks typically have lower energy consumption per byte sent and received when compared to cellular mobile networks.
  • Windows 8 BootCamp

    1. 1. Developing on Windows 8 Power point template by Colin Eberhardt
    2. 2. AgendaWinRT Platform BasicsBest practicesPickersContractsTilesNotificationsProcess Lifetime Management
    3. 3. Who am I Einar Ingebrigtsen @einari einar@dolittle.com http://blog.dolittle.com http://www.ingebrigtsen.info
    4. 4. The target
    5. 5. Old school interop
    6. 6. Windows RT style
    7. 7. Architecture
    8. 8. Projections
    9. 9. Collections
    10. 10. Bridging the gapFileOpenPicker picker = new FileOpenPicker();picker.FileTypeFilter.Add("*")a;StorageFile file = await picker.PickSingleFileAsync();Windows.Storage.Streams.IInputStream inputStream = await file.OpenReadAsync();System.IO.Stream stream = inputStream.AsStreamForRead();System.IO.StreamReader reader = new StreamReader(stream);string contents = reader.ReadToEnd();
    11. 11. APIs
    12. 12. Missing thingsReflection API changed Type details through GetTypeInfo() – extension method Emit namespace practically empty - security
    13. 13. XAMLOriginally developed for Windows Vista andexposed as WPFDefines what you seeLayout is by default not flowing, as in HTMLCan observe changes (Active View)
    14. 14. Tools
    15. 15. Dependency ObjectContains property bag forDependencyProperties on objectHolds attached Dependency PropertiesDataContext aware
    16. 16. Dependency PropertiesA bindable property that can hold bindingexpressionsRegistered on a DependencyObjectCallback when data changes
    17. 17. Attached Dependency PropertiesCross cutting propertiesExtend other dependency objects withproperties they don‟t have
    18. 18. DataContextHierarchical Children uses parents datacontext unless explicitly changing it Set DataContext = “Hello World” DataContext = “Hello World” Set DataContext = “Something else” DataContext = “Something else” DataContext = “Hello World”
    19. 19. BindingSource Defaults to DataContext Can use StaticResource as sourceMode OneWay, TwoWay, OneTime – OneWay defaultValidation ValidatesOnException ValidatesOnNotifyDataErrors INotifyDataErrorInfo
    20. 20. BindingStringFormat StringFormat = „MMM.dd.yyyy‟Null and Fallback values TargetNullValue=„(None)‟ FallbackValue=„(Data Context Not Set)‟IValueConverter
    21. 21. Element to ElementCan bind directly to other elementspropertiesBinds by name of element
    22. 22. Active ViewINotifyPropertyChanging / INotifyPropertyChangedINotifyCollectionChanged – ObservableCollection<>
    23. 23. ValueConverterSimple interface; IValueConverter Convert ConvertBackConverts values during databinding
    24. 24. TypeConverterConverts data from XAML to CLR types and backXAML will always give stringCan be defined on a DependencyProperty or on an objectwith attributes pointing to the converter
    25. 25. EventsYou still have events as before – buttons canbe clicked and raise an eventRoutedEvents – bubbles through the UI
    26. 26. Asyncvar data = DownloadData(...);ProcessData(data); STOP DownloadData ProcessDatavar future = DownloadDataAsync(...);future.ContinueWith(data => ProcessData(data)); DownloadDataAsync ProcessData
    27. 27. Async ModelsWindows Runtime : IAsyncOperation<T>.NET Framework : Task<T>C# 5.0 – async / await
    28. 28. Async – C# styleMarked with “async” modifierMust return void or Task<T>Use “await” operator to cooperatively yieldcontrol – remember to mark with “async”Feels just like good old synchronous code
    29. 29. Patterns & PracticesMVVM Inspired by PresentationModel by Martin Fowler Good for decoupling – promotes testabilityCompositioningCommandsActions / Triggers / Behaviors
    30. 30. MVVM Model View Observes ViewModel Observable
    31. 31. Compositional UIs Navigation Header Main Content Footer
    32. 32. Event AggregatorViewModel 1 ViewModel 2 Aggregator
    33. 33. TilesTap on tile to launch or switch to an appStatic default tile specified in app manifestTwo sizes:Both sizes can have live updates
    34. 34. Live TilesTiles updates using Templates provide Text-only image-onlypre-defined templates rich rendering options or combinationJPEG or PNG only, Optional “peek” Local or cloudmax size 150 KB animation updates
    35. 35. Notification Queuing
    36. 36. Secondary Tiles
    37. 37. Process Lifetime ManagementSystem manages application lifetimeOne foreground full screen windowApps are quickly suspended to preservebattery life
    38. 38. SuspendSystem resources focused on the app thatthe user is interacting with in the foregroundInactive apps have no impact on battery lifeor responsiveness, they are suspended bythe OSEnables instant switching between apps
    39. 39. Suspend detailsSuspended apps are not scheduled by the NT KernelNo CPU, Disk or Network consumedAll threads are suspendedApps remain in memoryKernel ensures apps are not suspended in critical sections that couldcause system wide deadlocksApps instantly resumed from suspendwhen brought to foreground
    40. 40. Session StateSuspensionManager SessionState Property bag that is automatically serialized and saved when suspended Reloads property bag from disk on activation Does not reload state if app crashedOnly save and restore user session metadataTip: Don‟t wait till suspension to put data into SessionState
    41. 41. Session State : Best practices User using app Launch Save incrementally Restore session App switch Resuming Save navigation Do nothing
    42. 42. TerminationUser explicitly closes the app: soft terminationSystem needs more memoryUser switch occursSystem shutdownApps crash Apps does not get notified when they are getting terminated
    43. 43. Process State Transitions User suspending Running Suspended Low Memory TerminatedLaunches App resuming App App App Splash Code gets to run No code runs App not running screen
    44. 44. Splash screenSystem provides splash screen mechanismShown while Windows launches your appPresented during activationDeveloper provides color and image in app manifestApps need to present a window within 15 seconds of activation or theapp will be terminated
    45. 45. Background Audio PlaybackApps can play audio in the backgroundDevelopers must specify background audio in the appmanifestEach audio stream is given a type (communication, media,game)Onle one audio stream type may play at a given time
    46. 46. Upload/Download in the backgroundUse the BackgroundTransfer API to upload or downloaddata over HTTP in the backgroundInitiate upload / download from the foreground and it cancontinue though your app is suspended
    47. 47. Background tasksTrigger / Condition based System events InternetAvailable NetworkStateChange OnlineIdConnectedStateChange SmsReceived TimeZoneChange Background tasks for lock screen capable apps Control Channel Timer Push Notifications System events for lock screen-capable apps UserPresent UserAway ControlChannelReset SessionConnected LockScreenApplicationAdded LockScreenApplicationRemoved
    48. 48. Background tasks : resources CPU resource quota Refresh period Lock screen appNon-lock screen app
    49. 49. Windows Notification ServiceEnables delivery of tile and toast notification over theinternetTile updates and notifications shown to the user even ifyour app is not runningWNS handles communication with your appScales to millions of usersWNS is a free service for your app to use
    50. 50. Push Notification Overview 1. Request Channel URI 2. Register with your Cloud Service 3. Authenticate & Push Notification
    51. 51. Toast NotificationsToast notifications deliver transient messages outside the context of theappUse toast notifications to get user‟s attention immediatelyUser is in control and can permanently turn off toast notifications fromyour appAllows quick navigation to a contextually relevant location in your appToast notifications are easy to invoke from your app or from the cloud
    52. 52. Toast TemplatesUses same template architecture as Live TilesRich set of rendering options available
    53. 53. ContractsContracts enable integrating the Windows 8 experience into your app Yields a consistent UI for all apps
    54. 54. SearchEnables your app to interact and respond to Suggestions Search Query
    55. 55. SettingsConsistently given one place to get search Context sensitive to the front facing app
    56. 56. ShareYour app can share anything (text, images, binaries) Automatically filters available applications to share toYour app can be a share target – receive sharing from others Add sharing target as a capability and you can receive share requests
    57. 57. Play ToAbility to stream media to compatible devices
    58. 58. DataIsolated Storage is the key http://metrostoragehelper.codeplex.comDatabase SQL Lite http://timheuer.com/blog/archive/2012/05/20/using-sqlite-in-metro-style-app.aspx
    59. 59. SummarizedWindows RT is a huge leap, both in faith but also technicallyConsistent API that feels mature from day oneWell architected solutions putting the user firstMakes us as developers focus on adding the business value
    60. 60. ResourcesThe samples of today http://github.com/einari/toodelooINPC Weaver http://github.com/SimonCropp/NotifyPropertyWeaverWinRT Toolkit http://jupitertoolkit.codeplex.comTiny IoC container - WinRT Compatible http://microsliver.codeplex.com/
    61. 61. ResourcesMVVM Light http://mvvmlight.codeplex.com/Setting up push notifications – registering your app https://manage.dev.live.com/buildWAT for Windows 8 + WnsRecipe http://watwindows8.codeplex.com/releases/view/73334Calisto – UI Framework for WinRT https://github.com/timheuer/callistoGet into the store – register as a deveveloper http://msdn.microsoft.com/en-us/windows/apps/
    62. 62. Thanks for your attention

    ×