InfoQ

InfoQ

News

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

Task Parallel Library for Silverlight

Posted by Jonathan Allen on Aug 25, 2011

Sections
Development
Topics
Silverlight ,
.NET ,
Rich Internet Apps ,
Concurrency ,
Programming ,
Task Parallel Library

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.

It may be MIT X11 licenced by 陈 国辉 Posted
Re: It may be MIT X11 licenced by Jonathan Allen Posted
F# Async Monad and Agents/Actors can be used in Silverlight Today by Faisal Waris Posted
Existing solutions from Microsoft today by Stefan Dobrev Posted
  1. Back to top

    It may be MIT X11 licenced

    by 陈 国辉

    Task Parallel Library for Silverlight is licensed under the same licenses as the rest of the Mono framework. What is mono framework?
    If mono framework = runtime libraries -> LGPL 2.0;
    If mono framework = class libraries -> MIT X11.
    I think TPL use MIT X11.

  2. Back to top

    Re: It may be MIT X11 licenced

    by Jonathan Allen

    How very embarrassing. You are correct, the class libraries are released under MIT X11.

    mono-project.com/FAQ:_Licensing

  3. Back to top

    F# Async Monad and Agents/Actors can be used in Silverlight Today

    by Faisal Waris

    Silverlight requirements are more for concurrency and IO parallelism rather than task parallelism.

    Sequencing async computations are a significant need.

    F# handles these quite well using functional paradigms.

    Learning F# / functional programming is an investment, no doubt, but its well worth the effort.

  4. Back to top

    Existing solutions from Microsoft today

    by Stefan Dobrev

    There are a couple of existing "solutions" that comes from Microsoft:


    • Use AsyncCtpLibrary_Silverlight.dll that comes with Visual Studio Async CTP.

    • Use Silverlight 5.


    However if you want to use the concurrent collections you will have to resort to bundling Mono's implementation. Maybe in the final version of Silverlight 5 they will include some of them, but nothing has been said publicaly.

    -sdobrev