BT
x Your opinion matters! Please fill in the InfoQ Survey about your reading habits!

Task Parallel Library for Silverlight

by Jonathan Allen on Aug 25, 2011 |

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.

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

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.

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

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.

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

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

4 Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT