Same issues. You want to access the pixels but the loading is asynchronously, so the pixel data was not loaded.
You should rather use the WBX method FromStream(stream)
Also, you can't create a WB on a background thread so running the creation of WBs needs to happen before your Parallel loop on the UI thread.
Something like this (not tested nor compiled);
WriteableBitmap currPicture = new WriteableBitmap((BitmapSource)(new __BitmapImage(new Uri(allPictures[i]))));__
Sometimes it might have been loaded but that's good luck.You should rather use the WBX method FromStream(stream)
Also, you can't create a WB on a background thread so running the creation of WBs needs to happen before your Parallel loop on the UI thread.
Something like this (not tested nor compiled);
var wbs = new List<WriteableBitmap>();
foreach(var fileName in Directory.GetFiles(selectFolder(), filePrefix + "*.png", SearchOption.AllDirectories))
{
using(var stream = File.OpenRead(fileName))
{
var wb = BitmapContext.New(1, 1).FromStream(stream);
wbs.Add(wb);
}
}
Parallel.For(0, wbs.Count, i =>
{
var currPicture = wbs[i];
SumPictures(currPicture);
if (i == 0)
...