BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Task Parallel Library for Silverlight

Task Parallel Library for Silverlight

Silverlight’s asynchronous service model forces developers to deal with multi-threading from the very beginning. So it seems odd that Microsoft choose to omit the Task Parallel Library, which is the core of .NET’s multi-threading infrastructure. Fortunately there are options.

If the LGPL 2.0 license isn’t an issue for you, you can use a port of the Mono implementation. Robert McLaws and Jrmie "Garuma" Laval have done just this, and published their work on NuGet under the title Task Parallel Library for Silverlight - 2.0. Unfortunately they haven’t published a copy of the LGPL license, the source code, or the Mono copyright notifications. While this can be corrected, it does pose some legal problems in the meantime.

Working under the assumption that they will fix this oversight, here’s what you get in their package:

  • An implementation for both Silverlight 3 and 4
  • An implementation for Silverlight for Windows Phone 7 and 7.1
  • The Task Parallel Library itself (System.Treading.Tasks)
  • The Coordination Data Structures (System.Collections.Concurrent)
  • The cancellation infrastructure (i.e. CancellationToken)
  • Parallel for loops, but not parallel LINQ expressions

Another option is the PortableTPL by David Catuhe. This isn’t the real TPL, but rather a simplification originally designed to be educational. That said, it does run on Silverlight, Windows Phone 7, and XBox 360 and is available under the liberal Microsoft Public License. It has the core TPL features suchs as Tasks and cancellation, but lacks the Coordination Data Structures.

Rate this Article

Adoption
Style

BT