- Dev Blogs
- .NET Parallel Programming
.NET Parallel Programming
All about Async/Await, System.Threading.Tasks, System.Collections.Concurrent, System.Linq, and more…
Latest posts
What’s new in Beta 1 for Parallel LINQ (PLINQ)?
A number of improvements have been made to Parallel Extensions since the Visual Studio 2010 CTP across the Task Parallel Library (TPL), Parallel LINQ (PLINQ), and our coordination data structures. You can find the latest on TPL (1 2 3) and the data structures (link) on this blog. Here are the big changes to PLINQ since that CTP: With- Operators PatternTo parameterize PLINQ, we have added a set of controls beginning with With-. As we began to add controls to PLINQ, it became clear that pretty soon the number of overloads on AsParallel, Range, and Repeat would increase dramatically. ...
What’s new in Beta 1 for the Task Parallel Library? (Part 3/3)
Related posts: So what else is new in TPL for Beta 1 (finally)? In the last post, we mentioned that TaskFactory offers more static helper methods than just StartNew. In this post, we’ll cover those methods (FromAsync, ContinueWhenAll, and ContinueWhenAny) as well as the new TaskScheduler class.FromAsyncIn order to better to integrate the Asynchronous Programming Model (APM) with TPL, we added FromAsync to TaskFactory. Here’s an example for reading asynchronously from a FileStream:FileStream fs = ...;byte [] buffer = ...;Task<int> t = Task<int>.Factory.FromAsync( &nb...
What’s new in Beta 1 for the Task Parallel Library? (Part 2/3)
Related Posts: Last week we talked about changes under the covers, redesigns in System.Threading.Parallel, and using CancellationTokens. So what else is new in TPL for Beta 1? In this post, we’ll cover the new TaskFactory class, the plight of Future<T> (Task<TResult>), and TaskCompletionSource<TResult>.TaskFactoryThere are two ways to create and schedule Tasks: use constructors and instance methods, or use static methods like StartNew. In previous releases, these two functionalities were jammed into the Task class, and we realized that separating them would result in a c...
Do you use LazyInitMode.AllowMultipleExecution?
In an effort to release simple, streamlined APIs, we spend a lot of time poring over every aspect of our types.One of the types that we know is getting used a lot both internally and externally is LazyInit<T>. One of LazyInit<T>’s constructors takes in a LazyInitMode enum which allows you to initialize a value in one of three modes: AllowMultipleExecution is motivated primarily by performance. If we allow the threads to race, we don’t need to take a lock and will never need to block any of the threads attempting to initialize the LazyInit<T>. Additionall...
What’s new in Beta 1 for the Task Parallel Library? (Part 1/3)
Related Posts: The Task Parallel Library (TPL) has come a long way since its inception. Over the course of several CTPs, it has evolved to be an important and central new component in the .NET Framework. Most recently, TPL was released as part of mscorlib.dll in the Visual Studio 2010 and .NET Framework 4.0 CTP around the October 2008 timeframe. However, due to the nature of large software projects, that release was actually based on code from back in July! Needless to say, since last summer, we’ve invested a lot of effort into making sure that the right functionality is expos...
What’s new in Beta 1 for the coordination data structures?
We're currently working on the Beta of .NET 4.0 (no dates to announce) and there are lots o’ new stuff for the Parallel Extensions. We hope you’re as excited about it as we are. Given that we have so much coming down the pipes, we decided to roll out posts on what’s coming in digestible chunks. What’s better to start with than the low-level infrastructure? In addition to the coordination data structures, you can expect posts on changes in the Task Parallel Library (TPL) as well as Parallel LINQ (PLINQ) and a few miscellaneous topics. New Types Since our last CTP in September ‘08, we’ve added a few new types ...
Maestro has its own blog!
The response to our initial post on this blog about Maestro has inspired us to give it its own blog. If you’re not yet in the know, Maestro is a new incubation language from Microsoft’s Parallel Computing Platform team for safe and scalable parallel programming for .NET. If you have interest in Maestro or any topics related to isolation, agents, message-passing, safety, incubation, etc. we encourage you to check it out, subscribe to the feed, and tell your friends. They just might buy you better birthday presents for the tip. :)https://blogs.msdn.com/maestroteam
Getting random numbers in a thread-safe way
It’s very common in a parallel application to need random numbers for this or that operation. For situations where random numbers don’t need to be cryptographically-strong, the System.Random class is typically a fast-enough mechanism for generating values that are good-enough. However, effectively utilizing Random in a parallel app can be challenging in a high-performance manner.There are several common mistakes I’ve seen developers make. The first is to assume that Random is thread-safe and is ok to be used concurrently from multiple threads. This is a bad idea, and can ...
“Session-in-a-box” on Parallel Programming with .NET 4.0
At PDC 2008 and TechEd EMEA 2008, Daniel Moth delivered several hit talks on parallel programming with the .NET Framework 4.0. The videos of both of those talks are available online, and he’s since created a series of blog posts capturing the content from those sessions in a way that should make it easy for others to re-present the content. Definitely worth a look: https://www.danielmoth.com/Blog/2009/02/give-session-on-parallel-programming-or.html.Thanks, Daniel!