Thanks for the explanation.
The issue I face is that I get the depth picture from your plug-in and then I start a thread for processing the depth data.
mainly in the thread I lock the texture with read and fill an array. but your then the process was crashing with error referring to the lines I posted for you.
I think your mutex somehow does not apply to my thread and error happens in the write data to the texture memory.
I solved the issue by some lock and null check, but then I found out that it is speed dependent, meaning that when I decrease the frame rate and make the app slow then the same issue happens