I need to update the pixels of the image asynchronously. I have a problem with a solution that was suggested in this topic - topic. So, the following code called from non UI thread. The application stops responding during the execution of this code:
Dispatcher.Invoke(() =>
{
_bitmap.Lock();
pBackBuffer =_bitmap.BackBuffer;
});
unsafe
{
Marshal.Copy(_displayPixels, 0, pBackBuffer, _displayPixels.Length);
}
Dispatcher.Invoke(() =>
{
_bitmap.AddDirtyRect(new Int32Rect(0, 0, DepthWidth, DepthHeight));
_bitmap.Unlock();
});
What am I do wrong?