Freigeben über


PPL and JavaScript: Bing Maps Trip Optimizer for Windows 8 Now Available on MSDN Developer Samples!

One of the things I like best about creating Windows 8 Metro style apps is that you can more easily combine the best of C++, JavaScript, and .NET languages into one app. For example, you can use JavaScript and HTML or XAML to define your UI and C++ to perform the computationally intensive parts. Another advantage of this model is that you can leverage code that you’ve already written and tested.

Previously, I invited you to check out the Bing Maps Trip Optimizer sample, which I wrote.  Bing Maps Trip Optimizer computes the shortest route among a set of locations. (This classic computing problem is also known as the traveling salesman problem.) The traveling salesman problem is traditionally solved by using a brute-force technique: compute each possible route among all locations and choose the shortest. This problem becomes exponentially more difficult as you increase the number of locations. Because a brute-force approach might not solve larger problems in a reasonable time, Bing Maps Trip Optimizer uses a technique known as ant colony optimization to more quickly and efficiently approximate the shortest route.

The previous version used JavaScript and HTML to define the UI, and an ActiveX control written in C++ to optimize the trip. Last week, we released a version that runs as a Metro style app. This version leverages the JavaScript and HTML code from the previous version to define the UI, and also leverages the existing C++ code to perform the route optimization. And because the Windows Runtime handles all the interop between JavaScript and C++, the new version no longer requires any “glue” code to make it all work.

The version that runs as a Metro style app demonstrates many of the new features that are part of the Parallel Patterns Library, for example:

· How to use create_async and progress_reporter to define asynchronous operations that can be consumed by other components.

· How to use task and when_all to create a chain of continuation tasks that perform a larger task.

· How to use cancellation tokens to cancel long-running tasks, and how to invoke PPL task cancellation from JavaScript.

· How to use task_completion_event to make XML HTTP Request (IXHR2) operations useful with other PPL tasks.

The sample also explains how we migrated the existing app for use as a Metro style app.

Visit Bing Maps trip optimizer sample to download the sample code and Developing Bing Maps Trip Optimizer, a Metro style app in JavaScript and C++ to read more about how the sample works. The sample is also part of the Windows 8 Consumer Preview Metro style app samples for C#, Visual Basic, C++, and JavaScript.

Also, don’t forget to grab a Bing Maps Key to run the sample.

We’d love to hear your feedback, both on the sample code and on your experience with the documentation. If you rate the documentation on the Windows Dev Center, please take an extra moment to tell us how you liked the content, and how we can improve it.