Showing results for June 2009 - .NET Parallel Programming

Jun 30, 2009
0
0

Asynchronous methods, C# iterators, and Tasks

Stephen Toub - MSFT Stephen Toub - MSFT

More and more, developers are realizing the significant scalability advantages that asynchronous programming can provide, especially as it relates to I/O. Consider an application that needs to copy data from one stream to another stream, such as is being done in the following synchronous implementation: static void CopyStreamToStream(Stream input...

Parallel ExtensionsTask Parallel Library.NET 4
Jun 24, 2009
0
0

Don’t dispose of objects that you don’t own

phillips.joshua phillips.joshua

In concurrent programs, race conditions are a fact of life but they aren’t all bad.  Sometimes, race conditions are benign, as is often the case with lazy initialization.  The problem with racing to set a value, however, is that it can result in multiple objects being instantiated when only one is needed.  Take the ...

Jun 24, 2009
0
0

Parallel For Loops over Non-Integral Types

Stephen Toub - MSFT Stephen Toub - MSFT

In a previous post, it was demonstrated how for loops with very small loop bodies could be parallelized by creating an iterator over ranges, and then using Parallel.ForEach over those ranges.  A similar technique can be used to write parallel loops over iteration spaces of non-integers.  For example, let’s say I wanted to ...

Parallel ExtensionsTask Parallel Library.NET 4
Jun 22, 2009
0
0

Cancellation in Parallel Extensions

Mike Liddell Mike Liddell

One of the great features that crosses all of Parallel Extensions types is a consistent approach to cancellation (see https://blogs.msdn.com/pfxteam/archive/2009/05/22/9635790.aspx). In this post we explore some of the ways cancellation is used in Parallel Extensions and explain the guidance we developed. The new cancellation system is a ...

Parallel ExtensionsTask Parallel Library.NET 4
Jun 19, 2009
0
1

Tasks and the Event-based Asynchronous Pattern

Stephen Toub - MSFT Stephen Toub - MSFT

As has been discussed previously, one of the new features in the Task Parallel Library is TaskCompletionSource<TResult>, which enables the creation of a Task<TResult> that represents any other asynchronous operation.  There are a wide variety of sources in the .NET Framework for asynchronous work.  One comes from components ...

Parallel ExtensionsTask Parallel Library.NET 4
Jun 13, 2009
0
0

How PLINQ processes an IEnumerable on multiple cores

Igor Ostrovsky - MSFT Igor Ostrovsky - MSFT

As Ed Essey explained in Partitioning in PLINQ, partitioning is an important step in PLINQ execution. Partitioning splits up a single input sequence into multiple sequences that can be processed in parallel. This post further explains chunk partitioning, the most general partitioning scheme that works on any IEnumerable<T>.Chunk partitioning ...

Parallel Extensions.NET 4PLINQ
Jun 9, 2009
0
0

Tasks and the APM Pattern

Stephen Toub - MSFT Stephen Toub - MSFT

The Asynchronous Programming Model (APM) in the .NET Framework has been around since .NET 1.0 and is the most common pattern for asynchrony in the Framework.  Even if you’re not familiar with the name, you’re likely familiar with the core of the pattern.  For a given synchronous operation Xyz, the asynchronous version ...

Task Parallel Library.NET 4Code Samples
Jun 6, 2009
0
0

Achieving Speedups with Small Parallel Loop Bodies

Stephen Toub - MSFT Stephen Toub - MSFT

The Parallel class represents a significant advancement in parallelizing managed loops.  For many common scenarios, it just works, resulting in terrific speedups.  However, while ideally Parallel.For could be all things to all people, such things rarely work out, and we’ve had to prioritize certain scenarios over others.One area ...

Parallel ExtensionsTask Parallel Library.NET 4
Jun 3, 2009
0
0

Mechanisms for Creating Tasks

Stephen Toub - MSFT Stephen Toub - MSFT

The core entity in the Task Parallel Library around which everything else revolves is System.Threading.Tasks.Task.  The most common way of creating a Task will be through the StartNew method on the TaskFactory class, a default instance of which is exposed through a static property on Task, e.g. var t = Task.Factory.StartNew(() => {  &...

Parallel ExtensionsTask Parallel Library.NET 4
Jun 2, 2009
2
1

The Nature of TaskCompletionSource

Stephen Toub - MSFT Stephen Toub - MSFT

The Task Parallel Library is centered around the Task class and its derived Task<TResult>. The main purpose of these types is to represent the execution of an asynchronous workload and to provide an object with a means to operate on that workload, whether it be to wait for it, to continue from it, or the like. The primary type of asynchronous...

Parallel ExtensionsTask Parallel Library.NET 4

Feedback