Nice article about Thread Concurrency and Synchronisation in C++11

I came across this nice article about modern thread usage patters in C++11:

It has a good summary of the synchronisation primitives available in C++11

GCC, std::thread – type ‘sleep_for’ is not a member of ‘std::this_thread’

If you are trying to use sleep_for() in the standard C++ thread library via GCC and are getting an error like the following:


‘sleep_for’ is not a member of ‘std::this_thread’


The you may have to define the following symbol:


More information can be found here.


Eclipse CDT – Using boost thread library with eclipse

If you are scratching your head about how to setup Eclipse and CDT to use the boost thread library then have a look at the first post in this thread:


It explains which project settings need to be changed.


Thanks to Robert!


.NET WPF, Set Bitmap – Must create DependencySource on same Thread as the DependencyObject error

In WPF when you try to assign a bitmap to a property that’s bound to a UI element from a worker thread you may get the following error:


“Must create DependencySource on same Thread as the DependencyObject”


A simple way around this problem without having to jump through hoops and dispatch to the UI thread is to just freeze the bitmap before assigning it, like this:


var bitmap = new BitmapImage(new Uri(CurrentImageFilePath));
this.CurrentImage = bitmap;


I hope this helps someone who’s stuck with this annoying error!