PPL Asynchronous Sample Pack Updated

Visual Studio 11 Beta has been a great source of customer feedback for us on the PPL team. If you’re a PPL user, thanks for staying in touch! We welcome all constructive feedback and your input helps us build a product that’s relevant to you.

A lot has happened with PPL since the last release of Visual Studio. One of the things that we’re excited about is the support for Windows 8 asynchrony. The feature that we released as a sample compatible with the Windows 8 Developer Preview is now officially part of the product. PPL is now the way to consume and produce Windows 8 asynchronous operations in C++!

Today, we’re releasing an updated version of our async sample pack. The update serves several purposes:

-     The new sample pack is compatible with Windows 8 Consumer Preview.

-     We want to demonstrate some of the more advanced uses of asynchrony in PPL.

-     We want to show you some of the forward-looking ideas we’re considering for PPL.

The last point is important. We have plenty of great ideas for PPL, but we have to face the reality – this product is nearing the release date and only the most critical things make the cut. We’re already thinking about the future, and knowing what you care about will help us focus on the right things.

A Quick Overview

Below is an overview of the samples we released:

-     FileAccess. This sample shows the basics of opening, reading, writing and deleting files.

-     ChunkyFileCopySample. This sample shows how to copy a file one chunk at a time using the new create_iterative_task construct, and how to cancel the copy process by cancellation_token.

-     FileCompressionSample. This sample demonstrates using WinRT compression API to compress and decompress file asynchronously.

-     MergeSortSample. This sample demonstrates how to implement a more advanced MergeSort algorithm with asynchronous programming pattern.

-     ImageCartoonizer. This is a hybrid application that has the “back-end” part implemented in C++ with PPL, exposing the asynchronous operation via the create_async method that are consumed in the “front-end” written in JavaScript.

-     NQueens. Another hybrid application that implements the classic N-Queens solver and showcases cancellation to interrupt the operation.

-     Quize. Here we show the when_any and create_delayed_task primitives to implement a simple puzzle game. To learn more about these PPL features, you can start with this introductory article in the MSDN Magazine, and get even more information from the MSDN. We are planning to cover these features in more details on follow up blogs, so stay tuned!

Extra! Extra!

You can find a few useful utilities in the extras namespace. Among them are:

-     The create_task function is a simple shorthand for the task constructor. Unlike the constructor, you can use with the auto keyword, or create continuations chains in a functional style without introducing temporary objects.

-     The create_iterative_task method helps you build an asynchronous loop. Suppose you want to read and process a file line by line without blocking, and close the file after you’re done reading it. All you need is a file reader object that yields one line at a time, and a call to the create_iterative_task method, that accepts a lambda that will be invoked for each line of the file. The ChunkyFileCopySample shows how this can be done.

-     The create_delayed_task is used to create a task that starts after a specified delay. It is especially useful when you want to setup a timeout for some long running tasks.  To do so, you need to use when_any method to create a task can be triggered by both your long running task and create_delayed_task, and execute the continuation when any of them completes first. Quize sample shows how this can be done.

We Want to Hear From You

So download the sample pack and tell us what you think. What features do you find the most useful? What do you think we missed?


Hong Hong
PPL Team


Comments (3)

  1. Peter says:

    Is there a new version for Windows 8 Release Preview? The march samples could not be compiled with RP. Thanks.

  2. Peter,

    We just updated it. Please try downloading it again and tell us if you see any issues.


  3. Patrick says:

    Will there be an updated version for VS2015, Windows 10 / the universal app framework? For example ppltasks_extra.h which contained create_iterative_task seems to be no longer available.

Skip to main content