Showing results for Code Samples - .NET Blog

Dec 9, 2009
Post comments count0
Post likes count0

A Tour Through the Parallel Programming Samples for .NET 4

Stephen Toub - MSFT
Stephen Toub - MSFT

On Code Gallery, we have a plethora of samples that highlight aspects of the .NET Framework 4 that help with writing scalable and efficient parallel applications.  This post examines each of those samples, providing an overview of what each provides.

.NET Parallel Programming
Dec 6, 2009
Post comments count0
Post likes count0

Updated samples for parallel programming

Stephen Toub - MSFT
Stephen Toub - MSFT

We've refreshed our samples for parallel programming with the .NET Framework 4.  Thanks to the gracious assistance of the fabulous Lisa Feigenbaum and others on the Visual Basic team, in this refresh the majority of the samples are now available not only in C# but also in Visual Basic. The samples are available for download at https://code.msd...

.NET Parallel Programming
Nov 2, 2009
Post comments count0
Post likes count0

Samples for Parallel Programming with the .NET Framework 4 Beta 2

Stephen Toub - MSFT
Stephen Toub - MSFT

We've posted a whole bunch of samples on Code Gallery showcasing how to use the new parallelism support in the .NET Framework 4.  You can find them at https://code.msdn.microsoft.com/ParExtSamples.  Enjoy!

.NET Parallel Programming
Oct 12, 2009
Post comments count0
Post likes count0

Parallelized Map and Filter Operations

Stephen Toub - MSFT
Stephen Toub - MSFT

Common operations like map and filter are available in parallelized form through PLINQ, though the names differ.  A map can be achieved with PLINQ’s Select operator, and a filter with PLINQ’s Where operator.For example, I could implement a ParallelMap operation that takes in one array and returns another as follows: public static...

.NET Parallel Programming
Sep 22, 2009
Post comments count0
Post likes count1

TaskScheduler.FromCurrentSynchronizationContext

Stephen Toub - MSFT
Stephen Toub - MSFT

The Task abstractions in .NET 4 run on instances of the TaskScheduler class.  Two implementations of TaskScheduler ship as part of the .NET Framework 4.  The first is the default scheduler, which is integrated with the .NET 4 ThreadPool and takes advantage of its work-stealing queues.  The second is the type of TaskScheduler returned...

.NET Parallel Programming
Aug 12, 2009
Post comments count2
Post likes count0

Implementing Parallel While with Parallel.ForEach

Stephen Toub - MSFT
Stephen Toub - MSFT

The Parallel class in .NET 4 includes methods that implement three parallel constructs: parallelized for loops (Parallel.For), parallelized foreach loops (Parallel.ForEach), and parallelized statement regions (Parallel.Invoke).  One of the interesting things about Parallel.Invoke is that, in some cases and at least in the current implementatio...

.NET Parallel Programming
Jun 30, 2009
Post comments count0
Post likes count0

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

.NET Parallel Programming
Jun 24, 2009
Post comments count0
Post likes count0

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

.NET Parallel Programming
Jun 22, 2009
Post comments count0
Post likes count0

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

.NET Parallel Programming
Jun 9, 2009
Post comments count0
Post likes count0

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

.NET Parallel Programming