Building Windows Runtime Components in C Harry Pierson
Building Windows Runtime Components in C++ Harry Pierson Program Manager, Windows Runtime Experience Team Microsoft Corporation
What is the “Windows Runtime”? The new API surface area in Windows 8 that’s available to C++, Java. Script, C# and Visual Basic.
Windows 8 Platform Core System Services Model Controller View Metro style Apps HTML / CSS XAML C C++ Desktop Apps C# VB Java. Script (Chakra) HTML C C++ C# VB Internet Explorer Win 32 . NET / SL Java. Script Win. RT APIs Communication & Data Graphics & Media Application Model Devices & Printing Windows Core OS Services
What is the “Windows Runtime”? The new API surface area in Windows 8 that’s available to C++, Java. Script, C# and Visual Basic. The low-level system infrastructure that enables language projection of APIs.
You can leverage the Windows Runtime in order to build your own APIs that project into C++, Java. Script, C# and VB.
Language Projection C++ Win. RT C#/VB JS
Win. RT Component Authoring Choices C# / VB C++/CX C++ with WRL
C++ Win. RT Components Reasons Performance Battery Efficiency Access to Win 32 Decompilation Protection Existing Code
C++ Hybrid App Scenarios HTML/JS Front End C#/VB Front End C++ Win. RT Components C#/VB Win. RT Components
Building C++/cx Win. RT Components demo
Win. RT is a marshaling boundary. Favor course-grained APIs over fine-grained.
Marshaling Example: Array vs. Vector //marshals entire array at once void const Array int for auto //marshals each call to Size and Get. At separately void IVector. View int for auto
Win. RT only provides async methods for all potentially long running operations. Favor async methods and use PPL to implement them.
Async Example IAsync. Operation int return //do long running operation here return IAsync. Operation<String^>^ return String //do long running operation here return ref new String "What do you get if you multiply six by nine? "
Win. RT doesn’t allow UI updates from background threads. Use Core. Dispatcher to fire events on the correct thread
Event Firing Example auto this //get window via Core. Window: : Get. For. Current. Thread ref new this nullptr
Leverage the Win. RT Infrastructure of Windows 8 Build Win. RT Components that can be used in C++, Java. Script, C# & VB apps. Be mindful of threading and marshaling boundaries.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U. S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
- Slides: 18