With the release of. NET 4, the. NET platform for parallel programming is a breeze. In fact, Microsoft provides you with three basic functions for parallel programming. The first is the Concurrency Runtime (concurrency Runtime) that is provided to C + +, and the second is by using the. NET platform provides a set of parallel programming functions for managed languages (including TPL, PLINQ, and parallel programming data structures, etc.), and the last one is based on the parallel programming features of F # itself.
However, because of the streamlining, the current coreclr does not include a parallel function library in. NET 4, making it impossible to directly gain the ability to parallel programming in Silverlight, even in the latest Silverlight 4. But let's not be discouraged, we can also use F # in Silverlight to implement parallel programming.
Bart Czernicki Detailed this approach in his blog, Silverlight 3 and F # Support in Visual Studio 2010. In this blog post, Bart gives the concrete steps to use F # for parallel programming, the corresponding sample code, and the discussion of performance, and a very interesting point of view:
Concurrent programming is the largest feature of Silverlight beyond other RIA technologies.
Bart also mentions the benefits of using F # to assist in parallel programming in Silverlight:
Do not have to explicitly start and stop a thread (for example, call Thread.Start)
No need to use BackgroundWorker
No callback required (AsyncCallback)
No need to follow asynchronous patterns such as BeginExecute
Of course, there are many drawbacks to implementing parallel programming in Silverlight through F #:
You cannot use PLINQ
If your code is written mainly by C # and VB, you can only write a wrapper in F # to implement parallelism in disguise.
Currently this is only available on Silverlight 3 because F # Runtime for Silverlight publishes only the Silverlight 3 version, whereas Silverlight 4 version of F # runs in Silverlight 4 The Tools for VS2010 are available when they are officially released.
For the last point above, Gaston Hillar's Blog "Silverlight 4 RC stays with the" old. NET Threads; F # helps has also been mentioned.
However, while we can now work on parallel programming in Silverlight, we still want Microsoft to provide direct parallel programming capabilities in future Silverlight versions.