Task Parallel Library / TPL

It has been very long since my last post here – I was really busy at work. But I will try to “fix it”! :)

I don’t know where Sacha Barber finds time for all his articles and “hobby” projects, but I am glad he does! One of the latest subjects of his investigations is Task Parallel Library (or TPL in short), one of the new parts of .NET 4:

  1. Part 1: Starting Tasks / Trigger Operations / Exception Handling / Cancelling / UI Synchronization
  2. Part 2: Continuations / Cancelling Chained Tasks
  3. Part 3: Parallel For / Custom Partioner / Aggregate Operations
  4. Part 4: Parallel LINQ
  5. Part 5: Pipelines
  6. Part 6: Advanced Scenarios / v.Next for Tasks

Managed/Native Debugging in C#/C++

I had a problem debugging my solution consisting of C#, C++/CLI, and native C++ projects. I was not able to get breakpoints working in the native C++ parts – after running the solution with breakpoints set, they were turning gray with warning sign, and their tooltip stated that “The breakpoint will not currently be hit. No symbols have been loaded for this document.” despite all debug properties were set right on those projects and all debugging symbols existed. After fighting it for a few hours and almost giving up, I started to think that the problem might not be with the native C++ projects, but rather somewhere else, e.g. in the StartUp project, which is C#. Checked that project’s properties, and guess what! Debug > Enable unmanged code debugging option was off!!! Switched it on, and voila – breakpoints work fine in native C++ DLL now!!! :)

How to Enable Using the Binding Builder in WPF and Silverlight Applications

In VS2010, when the Data Sources Window is used to generate the UI, the generated XAML injects design-time information so that the Binding Builder can be used to create bindings for the UI controls. But if your application was written in Visual Studio 2005 or 2008, or you used the XAML Editor, the Designer or Expression Blend without the Data Sources Window, your coding style is to assign the DataContext in code and not data bind to CollectionViewSources in your XAML, then you won’t be able to take advantage of the new Binding Builder. How to Enable Using the Binding Builder in WPF and Silverlight Applications by Karl Shifflett to the rescue – it demonstrates the simple requirements to enable you to use the new Binding Builder in a variety of scenarios like the ones mentioned above.

Threading in C#

Joseph Albahari, the author of C# 3.0 in a Nutshell, C# 3.0 Pocket Reference, and LINQ Pocket Reference as well as LINQPad, has very nice Threading in C# article (well, it is 77 pages long and available in PDF format as well). As the author says, “[it] tackles difficult issues such as thread safety, when to use Abort, Wait Handles vs Wait and Pulse, the implications of Apartment Threading in Windows Forms, using Thread Pooling, Synchronization Contexts, Memory Barriers and non-blocking synchronization constructs.”