Browse by Tags
All Tags »
Thread (
RSS)
Async / Await for .NET 4, Silverlight and Windows Phone if you have to target .NET 4, Silverlight and Windows Phone and still want to use the async / await pattern. the BCL team provide you with a new NuGet package named Microsoft.Bcl.Async . this package was announced as stable a few week ago. so you can check it out if you're having VS 2012 but should target one of the above platforms. be aware that this package won't work with 2010.
EF 6: Async this post is the first in a series about what's new in EF 6 . great improvements are about to come with Entity Framework 6 . it is a major release and the first one since EF become an open source. each post in the series will be dedicate to a single feature. this post will focus on a new EF a-sync features. the first question that should be asked is, why do we need parallel data access ? moreover why do we need a dedicate parallel data access API , rather then using the TPL Task.Run...
Parallel and The C# Memory Model Parallel programming can be tricky , both compiler and CPU's optimization can lead into a twilight zone's debugging. lets take the following code snippet snippet: Code Snippet class Program { static void Main( string [] args) { Console .WriteLine( "Start" ); var u = new Util (); u.Exec(); Console .ReadKey(); } } public class Util { private bool _stop = true ; public void Exec() { Task t = Task .Run(() => { bool b = true ; while (_stop) { b = ...
Will it crash my process here is a short question, it was taken from a real life bug that occurs at one of my customers . will the following code crash the process? Code Snippet List < object > items = new List < object >(); try { Parallel .For(0, 10000000, t => { items.Add( "1" ); }); } catch ( AggregateException ex) { } it is a non thread safe code that should throw an IndexOutOfRangeException. but it wouldn't crash the process, but what about the following code? Code...
Rx - Open Source Microsoft had announced the open sourcing of Rx . it is a great news for the Rx development community. Microsoft is still committed to the library's quality while accepting external contribution into the Rx code base. Open sourcing is the new Microsoft strategy and you can see other technology that is moving in that direction (for example ASP.NET). personally I will consider to move Visual Rx into an official Rx code base. central code base that is being managed by Microsoft...
Intel® VTune™ Amplifier XE this post will review the Intel® VTune™ Amplifier XE for parallel applications. when performance is matter you should go thought the process of performance improvement cycle. the cycle may be a bit different but the measurement step cannot be omit. at the measurement step you may evaluate different aspect like duration, memory, contention, cache behavior, CPU and cores utilization. profilers is one of the method which you can evaluate those aspects. different profiler...
Parallel.ForEach behavior this post is a direct continuation for the previous post about " Real-life story: Blocking Collection ". (Real-life story: Blocking Collection).ContinueWith (t => this post); or await (Real-life story: Blocking Collection); this post; my colleague Bram Veldhoen has suggest to demonstrate the behavior of the Parallel.ForEach thread's hunger in more pure fashion which doesn't include BlockingCollection<T> or any other high level Enumerable. the following...
Real-life story: Blocking Collection this post will discuss a real-life story which uncover none trivial (yet logical) behavior which related to Parallel.ForEach and BlockingCollection<T> . I will explain why it happens and what how can we handle it right. it all start when Guy Eden from ITG has found that the following code seem to leak memory : Code Snippet private static void Main() { var bc = new BlockingCollection < int >(); Task .Factory.StartNew(() => Parallel .ForEach(bc.GetConsumingEnumerable...
Tpl Dataflow walkthrough - Part 5 this post is a complete walkthrough of a web crawler sample that was build purely by using Tpl Dataflow . it was built on .NET 4.5 / C# 5 (on a virtual machine using VS 11 ). I will analyze each part of this sample, both by discussing the Dataflow blocks and the patterns in used. the sample code is available in here (it is a VS 11 project). during the walkthrough you will see the following Tpl Dataflow blocks: TransformBlock TransformManyBlock ActionBlock BroadcastBlock...
Rx - Aggregate vs. Scan this post will focus on 2 Rx operators Aggregate and Scan . both Aggregate and Scan are dealing with event stream accumulation , the only difference is that Aggregate produce single result (upon the stream completion) and Scan present an ongoing runtime accumulation which react for each OnNext . both operators has 2 overloads with the same signature: Code Snippet IObservable <TSource> Aggregate<TSource>( this IObservable <TSource> source, Func <TSource...
async \ await and Exception Handling this post will discuss how async / await is handling exceptions . as we mention in previous post , about the async / await concept, await is all about continuation . before .NET 4.5 parallel execution exceptions has to be handle in separate of the synchronic handling. for example: handling ThreadPool execution: Code Snippet void Foo() { try { Console .WriteLine( "Synchronic" ); ThreadPool .QueueUserWorkItem(state => { try { Console .WriteLine( "Parallel"...
the concept of async \ await in this post I will survey the new .NET 4.5 / C# 5 concept of async / await. I will focus on how to understand what is really happens behind the new async / await syntax. What's it all about? the new async / await syntax is using the C# syntactic compiler to generate async operation from code that is looking very much like a synchronous code. but before we start we should discus the new C# 5 syntax. the syntax include 2 keywords: async - which is only a marker...
TPL - Continuation this post will discuss TPL Continuation . TPL continuation can chain task into a pipeline . when dealing with dependencies between parallel work units, like [encoding -> compression -> encryption], continuation is the API for scheduling work unit upon completion of other work unit. the general idea is quit similar to the old APM pattern ( BeginXxx, EndXxx ) callback. basic completion the syntax of continuation: Code Snippet Task tsk = Task .Factory.StartNew(() => { /*...
Tpl Dataflow ( IDataflowBlock ) - Part 5 the previous post discus the concept ITargetBlock and ISourceBlock , which is the TDF consumer/Producer contract. you can find all the post in this series under the TDF tag. this post focus on the IDataflowBlock contract which is the life-time management contract for all data-flow's blocks. the IDataflowBlock define single property and 2 methods: Code Snippet public interface IDataflowBlock { Task Completion { get ; } void Complete(); void Fault( Exception...
Task != Thread whenever I teaching the Tpl Task subject I continually repeating the mantra which say that " task is a metadata/context of execution and it does not really responsible for the actual execution ". Task is a data structure which hold information about code execution, it's hold the delegate which will be execute, status, state, result, exception synchronization object, ext... but the responsibility of the execution is actually belong to the Task Scheduler . in matter of...
More Posts
Next page »