Browse by Tags
All Tags »
DEV »
Parallel (
RSS)
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...
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...
Rx - Exception Handling this post will discuss exception handling within the Rx arena. handling event stream exception is not trivial, for example observable should delegate exception to its subscribers though the OnError operation and cancel the subscription . on the other hand the subscriber may want to response OnError state by renewing its subscription or fallback to alternative stream . it is true that the Rx design guidelines suggest that faulted stream should not continue to produce data,...
async / await, some reasoning this post will try to make some reasoning about the .NET 4.5 / C#5 await keyword. I will begin with a quiz. how long will it take to the following method to produce the 42 value? Code Snippet async Task < int > Execute() { await Task .Delay(1000); await Task .Delay(1000); return 42; } you should remember that conceptually the await keyword will translate to a continuation . the above code can be compare to the following TPL 4 code snippet: Code Snippet Task <...
Using async / await this post will discuss parallel disposal. whenever we want to dispose a parallel execution upon completion we can't use the convenient using keyword. for example, the following code may be dispose the command before completion: Very bad Code Snippet using ( var conn = new SqlConnection (CONN_STR)) using ( var cmd = new SqlCommand ( "Select * from Employee" , conn)) { conn.Open(); cmd.BeginExecuteReader(ar => { int affected = cmd.EndExecuteNonQuery(ar); }); } the...
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"...
Rx - Sample this post will focus on the Rx Sample operator. the Sample operation does sampling the observable stream and forward less intensive data stream of the sampled datum. it can be prove very useful for scenario like handling accelerometer stream which can produce 60 value per second, in some cases we don't need such intensity and our machine resources may be happier to handle only 10 value per seconds. the same may be apply to video stream analytics and many other scenario. this is how...
Rx - Window continuing with the Rx series, this post will discuss the Window operator. in previous post I was discussing the Buffer operator which enable buffering of Rx datum stream into chunks. has good and useful as the Buffer operator is, it doesn't nail up every single scenario. let consider a scenario of tracing the highest and lower value within a time period . for example hourly tracking of a service monitoring which produce values every second. technically we can use the Buffer operator...
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(() => { /*...
Rx - Buffer this post is on of a series of post about Rx (Reactive Extension). in this one I will discuss the Buffer operator. no doubt that one of the most useful Rx operator is the Buffer . the Buffer operator enable to reduce a throughput pressure and gain better utilization of our resources. let take a scenario of monitoring data stream and persist the datum into database (or send it through a network boundaries). assuming the datum rate is 1 per millisecond, databases does not typically design...
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...
Is it faster? does the .NET 4.5 really run faster than 4? this post will summaries TPL Performance Improvements in . NET 4.5 . the TPL team has put lot of effort to dramatically improve the overall performance of .NET 4.5. the improvement was achieve both by execution and memory allocation optimization. in result .NET 4.5 parallelism is faster and more GC friendly . allocation optimization does improve the overall execution speedup, because GC collection does have significantly impact on the overall...
More Posts
Next page »