SlideServe
Menu
Préférences
© SlideServe · v2026

Building mixed-language apps

fedora avatar
31 diapositives · 460 Views · Jul 10, 2014

Building mixed-language apps. Alan Ludwig Senior Software Development Engineer 4-100. The Windows Runtime makes it possible for you to write great apps using more than one language. The Windows Runtime (WinRT). APIs. Cross-language i nfrastructure. A version of Windows.

Building mixed-language apps - slide 1
01 / 31Building mixed-language apps
1 / 17

Télécharger la présentation

Building mixed-language apps
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Building mixed-language apps Alan Ludwig Senior Software Development Engineer 4-100

  2. The Windows Runtime makes it possible for you to write great apps using more than one language

  3. The Windows Runtime (WinRT) APIs Cross-language infrastructure A versionof Windows

  4. What’s the best language foryour Windows 8 apps? • The language you already know • The language your component is already written in • The language that has access to the features you need • The language that provides the right performance • The language of your choice

  5. How do I do that? • When you write a Windows Runtime component,you can consume it in JavaScript, C#/VB, or C++

  6. The same cross-language infrastructure that was used to create thousands of Windows Runtime APIs is available for you to write your own Windows Runtime APIs

  7. Hybrid JavaScript and C++ Sample • Demo

  8. How do I make it great? • Only where needed • Keep it simple • Async everywhere • Mind your threads

  9. Only where needed • Indirect function calls • Type conversion

  10. Examples of type conversion

  11. Keep it simple • Designing good Windows Runtime interfaces is similarto good OO design

  12. Async everywhere • Use the async pattern for long running operations • The language projections make this easy

  13. Async operation in C++ • Windows::Foundation::IAsyncOperation<uint32>^ DemoLib::GetCountAsync() • { • auto async = concurrency::create_async( • // your lambda here • [this](){ return _count;} • ); • return async; • }

  14. Async operation in C# • public Windows.Foundation.IAsyncOperation<UInt32> GetCountAsync() • { • return (Windows.Foundation.IAsyncOperation<UInt32>)Task<UInt32>.Run( () => {return _count;} • ); • }

  15. Mind your threads • Writing great components requires some basic knowledge of threading issues

  16. UI is always thread affine

  17. Threading UI Thread Callasync API Create task Other work Update UI Continue Worker Thread Do work Call completion How do I get back to the main thread?

  18. Techniques to get back to the main thread • Dispatching via the UI element • Dispatching via the core window • Proxies and stubs

  19. Dispatching via the UI element • if (output->Dispatcher->HasThreadAccess()) • { • output->Text += "Count Changed (thread access)! Count is " + • newCount.ToString() + "\n"; • }

  20. Dispatching via the UI element • else{ • output->Dispatcher->RunAsync( • Windows::UI::Core::CoreDispatcherPriority::Normal, • ref new Windows::UI::Core::DispatchedHandler( • [this, newCount]() -> void { • output->Text += "Count Changed (no thread access)! Count is • " + newCount.ToString() + "\n";})); • }

  21. Dispatching via the core window • Windows::ApplicationModel::Core::CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync( • Windows::UI::Core::CoreDispatcherPriority::Normal, • ref new Windows::UI::Core::DispatchedHandler( • [this,value](){ • CountChanged(this, value);} • ));

  22. The Windows Runtime will automatically move your calls back to the right thread if proxies and stubs are available

  23. EventHandler vs. TypedEventHandler • event Windows::Foundation::EventHandler<uint32>^ CountChanged; • event Windows::Foundation::TypedEventHandler<IDemoLib^, uint32>^ CountChanged;

  24. Create proxies and stubs for yourWindows Runtime components

  25. Creating a Windows Runtime in-process component sample (C++/CX) • Demo

  26. The same cross-language infrastructure that was used to create thousands of Windows Runtime APIs is available for you to write your own Windows Runtime APIs

  27. How do I make it great? • Only where needed • Keep it simple • Async everywhere • Mind your threads

  28. Related Sessions • 10/30/2012 11:45 – B33 Baker – Bringing existing C++ code to Windows Store apps • 11/1/2012 12:00 – B33 Hood – Gaming reimagined: Gaming case studies A list of sessions will be sent one week prior to the event

  29. Resources • Hybrid JavaScriptand C++ sample • Creating a Windows Runtime in-process component sample (C++/CX) Please submit session evals by using the Build Windows 8 app or at http://aka.ms/BuildSessions

  30. Resources • Develop: http://msdn.microsoft.com/en-US/windows/apps/br229512 • Design: http://design.windows.com/ • Samples: http://code.msdn.microsoft.com/windowsapps/Windows-8-Modern-Style-App-Samples • Videos: http://channel9.msdn.com/Windows Please submit session evals by using the Build Windows 8 app or at http://aka.ms/BuildSessions