Thursday, May 26, 2011

.NET Framework 4 offers great multi threads tools and new API to handle the usage of it. One of them is the Parallel.Foreach method, which executes a foreach (For Each in Visual Basic) operation in which iterations may run in parallel. (You can see a good example of usage here on the MSDN website).

This method “makes life easy” in order to enable data parallelism over any System.Collections.IEnumerable or System.Collections.Generic.IEnumerable<T> data source.

On the other side, I am still working and maintaining some projects that had been coded using .NET 3 (C# 3.5) and in order to perform multi-threading processes there is a need to use some other complex API and manage it, such as: ThreadPool (in order to manage a pool of threads that can be used to post work items, process asynchronous I/O, wait on behalf of other threads, and process timers), WaitHandle which encapsulates operating system–specific objects that wait for exclusive access to shared resources, etc…

While reading some tech posts lately, I bumped into a great post that outline an implementation of this Parallel.Foreach method. You can find it in the link below and I think that it could make your life much more easier in order to perform and take advantage of multi-core processors and execute foreach loops in parallel.

Get it from here.

.NET 4 | C# | C# 3.5
Posted by: Eran Nachum (c)
Post Date: 5/26/2011 5:05:00 PM (Jerusalem Standard Time, UTC+02:00)
Disclaimer | | Trackback   #
 Monday, April 04, 2011

Hi,

I read a great post in the ADO.NET team blog in regards using the new EF 4 as a Unit of Work design pattern.

The main idea under this solution is to maintain all data manipulations against the DataBase easily and transactional, by encapsulating all data manipulation on POCO objects under a single DataContext and a single Save method.

This mechanism is usually recommended when working with asp.net MVC patterns, which each of the views is working with its specific controller that communicates with its model that implemented as a Repository pattern that exposes an interface of all methods signatures.

You can impress the post here.

Posted by: Eran Nachum (c)
Post Date: 4/4/2011 8:16:00 PM (Jerusalem Standard Time, UTC+02:00)
Disclaimer | | Trackback   #