Introduction to Windows Runtime (Winrt)

Introduction to Windows Runtime (Winrt)

Introduction to Windows Runtime (WinRT) Raffaele Rialdi @raffaeler [email protected] http://www.iamraf.net Tailored User Experience full screen different resolutions Immersive Multiple live tiles form factors Engaging secure, and Alive trustable Inspiring Confidence Metro Connected Multitasking use live data Touch-first fast and fluid small devices Current problems • No marketplace: how can you trust an application? • Admin privilege is required to install most Apps • Interoperability is difficult (PInvoke / COM) –Memory and Performance costs are high –Accessing OS API can be tough • Mixing native and managed language is hard • "C" APIs lifecycle is error-prone (CreateFile … CloseHandle) • I/Os are blocking (network, storage, …) • No standards for App to App communication • Search, Tweets, Facebook posts, … Windows Runtime Architecture Metro apps Desktop apps Win MFC XAML DirectX HTML WPF SL HTML form DX Language Projections .NET / Js / C++ .NET / Js / C++ Filtered access BCL / libraries to WinRT Windows Runtime APIs and Services UI Controls Storage Media Win32 Win32 Windows Metadata XAML Pickers Network … Runtime Broker Windows Runtime Core Windows Kernel Services What is the Windows Runtime? • It's the evolution of the Component Object Model (COM) • The infrastructure reuse old concepts like apartments, IUnknown and addref/release • IDispatch is gone, IInspectable is the new base interface • New support for Events (no connection points) and static types • Totally different Type System (no Variants, no BSTRs, …) • WinRT use ECMA-335 (.net Framework) metadata • WinRT and CLR talks the same "language" • No marshalling gotchas It's not a replacement for the CLR • CLR is required for managed languages infrastructure WinRT Type System • Basic types - bool, integers, floats, enum, guid, type, object • Strings - binary compatibile with .NET (string) and C++ STL (wstring) - are immutable - are value-types (non-nullable) • There are Reference Types - All types that implement WinRT interfaces • There are Value Types - All the others … for example arrays and structures - Structures can't declare reference (deep/shallow copy problem) • "Complex" types - Vector (collection) and Map (dictionary) - Vector<T> implements IObservableVector<T> that is mapped to INotifyCollectionChanged Language Projections Projections map WinRT types to the projected language • Different casing standards - Javascript (camelCase), C++ and .NET (PascalCase) • Developers need to understand edge-cases - Javascript standard only support IEEE-754 (floats). This means the max integer is 53 bit maximum • Few types are defined both in WinRT and .NET - They are treated as 'special' and seen as equivalent - INotifyPropertyChanged, INotifyCollectionChanged, … • Some .NET types cannot be mapped transparently - Streams, Buffers, Tasks are mapped via extension methods • I expect third party projections too - Java?, Python?, D language?, Delphi?, … Contracts : «XXI century's clipboard» • A standard way to "talk" to other Apps or OS services • A sort of publisher / subscriber pattern • Main Contracts available: • Search, Share, Protocol, PlayTo, App to App picking • WinRT activate Apps that expose Contracts • Running Apps is done via Launch Contract • Tiles are NOT shortcuts! • Apps use the Manifest to opt-in for Contracts • They receive parameters in the activation method Application Activation Explorer.exe Activate Activation RPCSS System Application.exe DCOM Class Launch Catalog Asynchronous by design Problem: Apps should never block UI thread Solution: API that may take more than 50ms are only async Special objects wraps Asynchronous Operations • In WinRT they implement IAsyncOperation<T> • AsTask extension method is used to convert it to a Task<T> • In .NET these objects are Task<T> • AsAsyncOperation extension method to obtain an IAsyncOperation<T> Tomorrow C# 5.0 have new async/await keywords Hall 4 - 10:45 Javascript and C++ can use "promises" pattern The sandbox Application Package Application code Manifest Marketplace Security Broker Proxy WinRT Libraries Win32 White-listed Windows Kernel Services Developing with WinRT • XAML UI for .NET and C++ • XAML / DirectX can share surfaces • DirectX inside a XAML control • Large virtual DirectX surface in conjunction with XAML • High Performance DirectX drawing, XAML overlapped • Custom WinRT components are easy to write • i.e. exposing C# or C++ code to Javascript or vice-versa • Custom components are private to the App (no RegSvr32) • Cross language calls are cheap • No more P-Invokes! • As fast as a vtable call • Desktop Apps can use a WinRT APIs subset • CLR have an additional weapon: "Portable Class Library" • A DLL with code that run on Metro, desktop, SL, … • As it's IL code, it runs as 32 or 64 bits as well Metro profile for .NET development Metro profile was a good opportunity to clean BCL • Removed: Xml DOM, WebClient, Threads, … • Moved Reflection in System.Reflection • GetTypeInfo extension method to access reflection classes Metro Fx 4.5 WP7 # assemblies 15 120 22 # namespaces 60 400 88 # types ~1'000 ~14'000 ~2'000 # members ~10'000 ~110'000 ~14'000 What else is not in the Metro profile? • APIs that are already in WinRT (Storage, Sockets, Network, etc.) • Server libraries like WCF, Asp.net, … • APIs that could bypass the sandbox • System.Data, Remoting, AppDomain, Private Reflection, … Developer thoughts • No need to elevate (UAC) a Metro App • Admin Apps will run in the old desktop • Storage • Apps can access only locations specified by manifest • Users can pick (via UI) a file that is stored elsewhere • No local db APIs at the moment • Media and Sensors • Easy access to cameras, accelerometer, … • Require user consent (requested via manifest) • Network • Great library to ease oAuth authentication • Flexible HttpClient replace WebClient • Websockets support • Dig into the APIs and discover it by yourself! Takeaways • WinRT is a great step in Windows evolution • Exposes native OS services in a pure OOP way • Closes the gap between managed and native languages • Developers can use their current knowledge to create Apps from small devices to classic PCs • Marketplace is an opportunity for developers and a sweet experience for end-users • Think about performance/battery issues • It's Framework.NET best friend Windows 8 Cheat Sheet C Charms Bar O Locks device orientation H Share charm Tiles to the left / right (.) K Connect charm Split left/right I Settings charm Temporarily peek at the desktop Cycle apps / Q Search pane F File Search Cycle input language & keyboard W Settings Search Narrator Z V Cycles through toasts Application Bar Tools for WinRT WinRT.codeplex.com (more to come …) Don’t forget to submit your feedback and win a great Nokia smartphone and Kindle e-reader! .

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    18 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us