Parallel.ForEach behavior

2012/02/27

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 code demonstrate the issue by using a slow Enumerable: Code...

Real-life story: Blocking Collection

2012/02/26

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(), i => { }));     Console.ReadKey(); } it was leaking even those the...

.NET 4.5 and C# 5 is approaching to matureness

2012/02/23

.NET 4.5 and C# 5 is approaching to matureness I have playing with the VS 11 preview for awhile and found it very stable and exciting. now the release date is getting match closer, the beta will be released (next week) on February 29th and it will come with “Go Live” license. as for small team and start up there is a very interesting announcement about Team Foundation Server Express Beta which is a great news and will make TFS's practice match more common than it is today. I'm certainly...
no comments

Rx and Time related operators

2012/02/14

Rx and Time related operators this post will focus on Rx's time related operators. Rx has lot to do with the time notion. actually Rx is kind of a time machine where datum does schedule for processing at specific time (I will talk about scheduling in future post). within the System.Reactive and System.Reactive.Linq namespaces we can find the following extension method and services. Window, Buffer and Sample which was spoken here, here and here. all operators has a time based overloads. Replay and Scheduler which I will...

Rx – DistinctUntilChanged

2012/02/02

Rx - DistinctUntilChanged this post will focus on the simple yet very useful DistinctUntilChanged operator. sometimes a datum stream may produce the same value for a while, you can see it in stock exchange stream the value of specific stock may be steady for a while. the observer can reduce its computation level by ignoring a repeatable value (sequential repeatable value, for none sequential you can use the Distinct operator). the DistinctUntilChanged is having the following overloads: Code Snippet IObservable<TSource> DistinctUntilChanged<TSource>(); IObservable<TSource> DistinctUntilChanged<TSource, TKey>(     Func<TSource, TKey> keySelector); IObservable<TSource>...