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...
(The full set of ParallelExtensionsExtras Tour posts is available here.)
The Task Parallel Library isn’t just about CPU-bound operations. The Task class is a great representation for any asynchronous operation, even those implemented purely as asynchronous I/O.Task’s ability to represent arbitrary asynchronous operations ...
(The full set of ParallelExtensionsExtras Tour posts is available here.)The Task Parallel Library provides the Task.Wait method, which synchronously waits for the target Task to complete. If the Task completed successfully, the method simply returns. If the Task completed due to an unhandled exception or cancellation, Wait throws ...
(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 ...
(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 ...
(The full set of ParallelExtensionsExtras Tour posts is available here.)Caches are ubiquitous in computing, serving as a staple of both hardware architecture and software development. In software, caches are often implemented as dictionaries, where some data is retrieved or computed based on a key, and then that key and its resulting ...
(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.&...
(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...
(The full set of ParallelExtensionsExtras Tour posts is available here.) An object pool is a mechanism/pattern to avoid the repeated creation and destruction of objects. When code is done with an object, rather than allowing it to be garbage collected (and finalized if it’s finalizable), you put the object back into ...
(The full set of ParallelExtensionsExtras Tour posts is available here.) The new .NET 4 System.Threading.ThreadLocal<T> is quite useful when you need per-thread, per-instance storage. This is in contrast to the fast ThreadStaticAttribute, which supports only per-thread storage (in .NET 4, ThreadLocal<T> actually ...