Showing results for Task Parallel Library - .NET Blog

Jun 1, 2009
Post comments count0
Post likes count0

Tasks and Unhandled Exceptions

Stephen Toub - MSFT
Stephen Toub - MSFT

Prior to the .NET Framework 2.0, unhandled exceptions were largely ignored by the runtime.  For example, if a work item queued to the ThreadPool threw an exception that went unhandled by that work item, the ThreadPool would eat that exception and continue on its merry way.  Similarly, if a finalizer running on the finalizer thread threw a...

.NET Parallel Programming
May 29, 2009
Post comments count0
Post likes count1

ParallelOptions.MaxDegreeOfParallelism vs PLINQ’s WithDegreeOfParallelism

Stephen Toub - MSFT
Stephen Toub - MSFT

We exert a good deal of effort ensuring that the APIs we provide are consistent within Parallel Extensions as well as with the rest of the .NET Framework.  This is from many angles, including behavior and general design, but also naming.  So when there are slight differences in naming, it raises questions.One occurrence of such a slight n...

.NET Parallel Programming
May 27, 2009
Post comments count0
Post likes count1

Exiting from Parallel Loops Early

Stephen Toub - MSFT
Stephen Toub - MSFT

Exiting out of loops early is a fairly common pattern, one that doesn’t go away when parallelism is introduced.  To help simplify these use cases, the Parallel.For and Parallel.ForEach methods support several mechanisms for breaking out of loops early, each of which has different behaviors and targets different requirements.ExceptionsIn ...

.NET Parallel Programming
May 26, 2009
Post comments count0
Post likes count1

Does Parallel.For use one Task per iteration?

Stephen Toub - MSFT
Stephen Toub - MSFT

In .NET 4, the new Parallel class provides For, ForEach, and Invoke methods for performing operations in parallel. One mental model that some folks use when thinking about Parallel.For is that it’s equivalent to running one System.Threading.Tasks.Task per iteration, e.g. that a loop like: Parallel.For(0, N, i => {   &n...

.NET Parallel Programming
May 20, 2009
Post comments count2
Post likes count0

Samples for Parallel Programming with the .NET Framework 4

Stephen Toub - MSFT
Stephen Toub - MSFT

Along with the release of the .NET Framework 4 Beta 1, we've just published a slew of samples that demonstrate using Parallel Extensions in a variety of ways.  You can download these from Code Gallery at https://code.msdn.microsoft.com/ParExtSamples.These samples include raytracers, a sudoku game, an image colorization algorithm, solvers for t...

.NET Parallel Programming
Feb 19, 2009
Post comments count0
Post likes count0

Getting random numbers in a thread-safe way

Stephen Toub - MSFT
Stephen Toub - MSFT

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 paral...

.NET Parallel Programming
Nov 4, 2008
Post comments count0
Post likes count0

.NET Framework 4.0 Poster for Download

Stephen Toub - MSFT
Stephen Toub - MSFT

Brad Abrams posted about a cool .NET Framework 4.0 poster which was distributed at the PDC last week and which you can download. Zoom in on the CORE section right in the middle for a glimpse into the parallelism support in .NET 4.0.

.NET Parallel Programming
Oct 28, 2008
Post comments count0
Post likes count0

Concurrent, Multi-core Programming on Windows and .NET

Stephen Toub - MSFT
Stephen Toub - MSFT

Thanks to everyone who attended our PDC pre-conference session yesterday on parallelism and concurrency!  We had a wonderful turnout at the event, and David, Joe, and I all had a terrific time. Attached to this post are the slides we presented. (It turns out that the PDC site does allow you to submit an evaluation for a precon.  If you at...

.NET Parallel Programming
Aug 7, 2008
Post comments count0
Post likes count0

ParallelWhileNotEmpty

Stephen Toub - MSFT
Stephen Toub - MSFT

Parallel Extensions includes the System.Threading.Parallel class, which provides several high-level loop replacement constructs like For and ForEach. In previous blog posts, we've taken a look at implementing other loops, such as for loops with arbitrary initialization, conditional, and update logic, range-based loops, and a parallel while.  T...

.NET Parallel Programming
Aug 5, 2008
Post comments count0
Post likes count0

Waiting for Tasks

Stephen Toub - MSFT
Stephen Toub - MSFT

Parallel Extensions makes it easy to wait for Tasks to complete.  Task exposes a Wait method, which can be used trivially: Task t = Task.Create(...); ... t.Wait();Task also exposes several static methods for waiting on an array of tasks, either for all of them to complete or for any of them to complete: Task t1 = Task.Create(...); Task t2 = Ta...

.NET Parallel Programming