I need to operate on bitmap pixels asynchronously. There is Bitmap and WriteableBitmap. I need something like:
public async Task<Bitmap> ProcessBitmap(Bitmap bitmap)
{
// operate on bitmap asynchronously
return newBitmap;
}
I wanted to use WriteableBitmap and convert it to stream and use stream async methods but PixelBuffer property seems unavailable in both WPF and WinForms. How should I do this? I could also use Parallel.For in some scenarios but how would I get result then?
var files = new [] { "c:\file1.bmp", "c:\file2.bmp" }; var tasks = files.Select(x => ProcessBitmap(x)); await Task.WhenAll(tasks). TheWhenAllwill wait for all tasks started to execute (here is you parallelism.