I have a problem with Boost threads. The program is a "for fun" program that draws the Mandelbrot set in DirectX 11. I want to use threads to be able to make use of a progress bar (or circle in this case), as it takes around 30-40 seconds to calculate the image at full HD on this computer. To calculate the image, I have a Mandelbrot class with a method "Calculate", which fires up 4 threads that split the calculation into 4 parts of the image. If I just instantiate an object of the Mandelbrot class, and call the Calculate-method, all works. However, I cannot use the progress circle this way. To do that, I want to fire up another thread, which has the Calculate method as starting point, and let the main thread go on with the progress circle business. This works sometimes, but most of the time, the application crashes and burns. Badly. Seems random when it crashes as well. Anybody have boost experience, perhaps in combination with DirectX 11?

I think I'm correct in that device context calls are not threadsafe, why I have arranged for a mutex to lock every time the device context is used. This should not be needed for the Direct3D Device, right?

If it crashes (which is most of the times I run it), only two of the calculate-threads terminate. The other two + the "CalcThread" do not finish. Any ideas?

I get an unhandled exception. It doesnt really give me much more information that this. I have only worked on this on my laptop. On my more powerful desktop, I have run it about 10 times in a row without crashes now. Starting to think it's just as simple as an "out of memory" issue. Could it be this?