Coordination Data Structures – WriteOnce<T>

This is an article in a series of blog entries describing a set of new Coordination Data Structures (CDS) introduced in the June 2008 CTP of the Parallel Extensions for .NET Framework. In C#, when a field declaration includes a readonly modifier, assignments to the fields introduced by the declaration can only occur as part…

1

Coordination Data Structures – SpinLock

This is an article in a series of blog entries describing a set of new Coordination Data Structures (CDS) introduced in the June 2008 CTP of the Parallel Extensions for .NET Framework. Waiting on locks usually result in a thread context switch and associated kernel transition which at times can be considered costly. On a…

5

Coordination Data Structures – LazyInit<T>

This is an article in a series of blog entries describing a set of new Coordination Data Structures (CDS) introduced in the June 2008 CTP of the Parallel Extensions for .NET Framework. LazyInit<T> provides support for several common patterns of lazy initialization. In here we will explore some of those patterns, but first a point…

2

How to consume REST services with WCF

As you are probably aware by now, Windows Communication Foundation (WCF) 3.5 introduced a new binding called WebHttpBinding to create and to consume REST based services. If you are new to the WCF Web Programming model then see here for more details. There have been many articles and blogs on how to host a RESTful…

30

More on self-replicating tasks

Some more stuff to remember when dealing with self-replicating tasks. (See my earlier post for an introduction to Parallel FX and self-replicating tasks): –          Self-replicating tasks should have an inter-replica communication mechanism for communicating the progress/details of the activity. This depends on what the activity is trying to achieve. See here for an example. –         …

1

WCF error handling and some best practices

I put together the following brief description of WCF Error Handling and some possible best practices for a customer. You may also find it useful:   There are 4 sets of errors that clients can expect:   Invalid configuration: when bindings, behaviors or any other configs are in conflict with some other settings. Communication errors:…

11

From Exceptions to Faults

A question that I often get asked during workshops on WCF is “Why does WCF use Faults instead of .NET Exceptions?” Exceptions expose a set of limitations and possible security risks: –          They are platform/technology specific: .NET exceptions may have no meaning on other platforms –          Exceptions can cause tight-coupling between clients and service. o  …

5

Digging deeper into PLINQ’s internal implementation

PLINQ is built on top of the Task Parallel Library (TPL) and promises to revolutionise the way we write programs that can benefit from the multi-core processor era. But how does it work internally? This article assumes that you are familiar with the basics of LINQ and have an understanding PLINQ and TPL. In this…

1

How to cancel a task in Parallel FX?

Task Parallel Library (TPL) allows you to easily cancel tasks. Effectively you need to call the Cancel method on the task in question. Imagine the simple sample below: Task task1 = Task.Create(Foo, 10000); static void Foo(object o) {   for (int i = 0; i < (int)o; i++)   {     // some code here…

3

Which memory model?

In his blog, Eric Eilebrecht explains why when writing multithreaded applications today we should stick to the weak ECMA memory model instead of CLR’s much stronger memory model. In principal, I have no issue with using a weaker model than the CLR memory model but my main concern is that “at what cost are we…

2