Quantcast
Channel: WriteableBitmapEx
Viewing all articles
Browse latest Browse all 360

Commented Unassigned: Crash when using WriteableBitmapEx.Clear in parallel. [20005]

$
0
0
Using WriteableBitmapEx 1.0.8.0 from NuGet, I have some code where I'm creating a bunch of images in parrel. However, inside BitmapContext there's a static Dictionary used in the ctor - which leads to crashes when calling methods such as WriteableBitmapExtensions.Clear on different images concurrently.

Here's some code to reproduce the problem

```
Parallel.For(0, 1000, i =>
{
var bitmap = new WriteableBitmap(100, 100, 96, 96, PixelFormats.Gray16, null);
var converted = BitmapFactory.ConvertToPbgra32Format(bitmap);
converted.Clear(Colors.Aqua);
});
```
Comments: ** Comment from web user: teichgraf **

Thanks for raising that and providing some solutions.
As you noted the lib is currently not really designed for multi-threaded scenarios. Most importantly since the WB ctor needs to be called on the UI thread anyway.
There was never a high demand for this. Actually it started with this issue report here. :) For now we won't invest in a redesign of the lib for various reasons including perf hits due to locking, etc.
If this issue report here receives more votes we might reconsider it.

Thanks!

- Rene


Viewing all articles
Browse latest Browse all 360

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>