1 / 18

Building Windows Runtime Components in C++

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++, JavaScript, C# and Visual Basic. Windows 8 Platform.

kathy
Download Presentation

Building Windows Runtime Components in C++

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Building Windows Runtime Components in C++ Harry Pierson Program Manager, Windows Runtime Experience Team Microsoft Corporation

  2. What is the “Windows Runtime”? The new API surface area in Windows 8 that’s available to C++, JavaScript, C# and Visual Basic.

  3. Windows 8 Platform Metro style Apps Desktop Apps HTML JavaScript HTML / CSS XAML View JavaScript (Chakra) C C++ C# VB Model Controller C# VB C C++ WinRT APIs Devices & Printing Communication & Data Graphics & Media System Services .NET / SL Internet Explorer Win32 Application Model Windows Core OS Services Core

  4. What is the “Windows Runtime”? The new API surface area in Windows 8 that’s available to C++, JavaScript, C# and Visual Basic. The low-level system infrastructure that enables language projection of APIs.

  5. You can leverage the Windows Runtime in order to build your own APIs that project into C++, JavaScript, C# and VB.

  6. Language Projection

  7. WinRT Component Authoring Choices • C# / VB • C++/CX • C++ with WRL

  8. C++ WinRT Components Reasons

  9. C++ Hybrid App Scenarios • HTML/JS Front End • C#/VBFront End • C++ Front End • C++ WinRT Components • C++ WinRT Components • C#/VB WinRT Components

  10. demo Building C++/cx WinRTComponents

  11. WinRT is a marshaling boundary. Favor course-grained APIs over fine-grained.

  12. Marshaling Example: Array vs. Vector //marshals entire array at once void ArraySample(constArray<int>^ ints) { for(auto x = 0u; x < ints->Length; x++) { autovalue = ints[x]; } } //marshals each call to Size and GetAt separately voidVectorSample(IVectorView<int>^ ints) { for(auto x = 0u; x < ints->Size; x++) { autovalue = ints->GetAt(x); } }

  13. WinRT only provides async methods for all potentially long running operations.Favor async methods and use PPL to implement them.

  14. Async Example IAsyncOperation<int>^ CalculateAnswer() { returnconcurrency::create_async([]() -> int { //do long running operation here return42; }); } IAsyncOperation<String^>^ CalculateQuestion() { returncreate_async([]() -> String^ { //do long running operation here returnref new String(L"Whatdo you get if you multiply six by nine?"); }); }

  15. WinRT doesn’t allow UI updates from background threads.Use CoreDispatcher to fire events on the correct thread

  16. Event Firing Example auto callback = [this](Object^ sender,InvokedHandlerArgs^ e) { this->Ticked(this->currentTick); }; //get window via CoreWindow::GetForCurrentThread window->Dispatcher->Invoke(CoreDispatcherPriority::Normal, ref new InvokedHandler(callback), this, nullptr);

  17. Leverage the WinRT Infrastructure of Windows 8Build WinRT Components that can be used in C++, JavaScript, C# & VB apps.Be mindful of threading and marshaling boundaries.

  18. © 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.

More Related