Showing results for Code Samples - .NET Parallel Programming

Nov 9, 2011
0
0

Exception Handling in TPL Dataflow Networks

Cristina Manu
Cristina Manu

A “dataflow block” is represented by a class implementing the IDataflowBlock interface. The state of a dataflow block is represented by the state of its IDataflowBlock.Completion Task, which itself has a Status property. When a dataflow block is in active state, meaning that it is currently doing processing or may do more processing in the future, ...

Parallel Extensions.NET 4.5Code Samples
Nov 8, 2011
0
0

ConcurrentDictionary Performance Improvements in .NET 4.5

Igor Ostrovsky - MSFT
Igor Ostrovsky - MSFT

ConcurrentDictionary is a popular concurrent data structure that was introduced in .NET 4. In the .NET 4.5 release, ConcurrentDictionary gets two performance improvements. One optimization is related to the way ConcurrentDictionary avoids torn reads and writes. To explain the background, all reference types and some value types are guaranteed to b...

Parallel Extensions.NET 4.5Code Samples
Jun 27, 2011
0
0

Using Tasks to implement the APM Pattern

Stephen Toub - MSFT
Stephen Toub - MSFT

Several times recently, folks have asked how to use tasks to implement the APM pattern, otherwise known as the Asynchronous Programming Model pattern, or the IAsyncResult pattern, or the Begin/End pattern.  While moving forward we encourage folks to use a Task-based pattern for exposing asynchronous operation, the APM pattern has been the prev...

Parallel ExtensionsTask Parallel Library.NET 4
Nov 21, 2010
0
1

Processing Sequences of Asynchronous Operations with Tasks

Stephen Toub - MSFT
Stephen Toub - MSFT

Of late, I’ve seen multiple folks asking about how to use tasks to asynchronously execute a sequence of operations.  For example, given three synchronous functions: public string DoA(string input); public string DoB(string aResult); public string DoC(string bResult); you could invoke these functions with code like: strin...

Parallel ExtensionsTask Parallel Library.NET 4
Aug 5, 2010
0
0

FAQ :: TaskScheduler.UnobservedTaskException event doesn’t work?

Danny Shih
Danny Shih

Recall that if exceptions thrown from Task bodies are left unobserved, they will be escalated.  In .NET 4, this means that TPL will throw them on the finalizer after the Task objects are available for garbage collection.  The UnobservedTaskException event on the TaskScheduler class was added as a last-resort method to observe such excepti...

Task Parallel Library.NET 4Code Samples
May 3, 2010
0
0

A TPL Sandbox

Danny Shih
Danny Shih

In a previous post, we introduced the UnobservedTaskException event, saying that it would be useful for host-plugin scenarios where a host application should continue to execute in the presence of exceptions thrown by buggy plugins.  A typical example is an Internet browser; should the entire application crash if some rich content plugin crash...

Parallel ExtensionsTask Parallel Library.NET 4
Apr 28, 2010
0
0

ParallelExtensionsExtras Tour – #14 – SingleItemPartitioner

Stephen Toub - MSFT
Stephen Toub - MSFT

(The full set of ParallelExtensionsExtras Tour posts is available here.) In a previous ParallelExtensionsExtras Tour blog post, we talked about implementing a custom partitioner for BlockingCollection<T>.  Custom partitioning is an advanced but important feature supported by both Parallel.ForEach and PLINQ, as it allows the develope...

Parallel ExtensionsTask Parallel Library.NET 4
Apr 27, 2010
0
0

ParallelExtensionsExtras Tour – #13 – AsyncCall

Stephen Toub - MSFT
Stephen Toub - MSFT

(The full set of ParallelExtensionsExtras Tour posts is available here.)Producer/consumer scenarios could logically be split into two categories: those where the consumers are synchronous, blocking waiting for producers to generate data, and those where the consumers are asynchronous, such that they're alerted to data being available and only then ...

Parallel ExtensionsTask Parallel Library.NET 4
Apr 15, 2010
0
0

ParallelExtensionsExtras Tour – #11 – ParallelDynamicInvoke

Stephen Toub - MSFT
Stephen Toub - MSFT

(The full set of ParallelExtensionsExtras Tour posts is available here.)  Delegates in .NET may have one or more methods in their invocation list.  When you invoke a delegate, such as through the Delegate.DynamicInvoke method, the net result is that all of the methods in the invocation list get invoked, one after the other.  Of...

Parallel Extensions.NET 4Code Samples
Apr 14, 2010
0
0

ParallelExtensionsExtras Tour – #10 – Pipeline

Stephen Toub - MSFT
Stephen Toub - MSFT

(The full set of ParallelExtensionsExtras Tour posts is available here.)  Producer/consumer is a fundamental pattern employed in many parallel applications.  With producer/consumer, one or more producer threads generate data that is consumed by one or more consumer threads.  These consumers can themselves also be producers of f...

Parallel Extensions.NET 4Code Samples