After getting much improvement, it´s still one issue that concerns me. And that is the sync between my 2 threads.
I use AutoResetEvent, but sadly, it has some delay with it, and would love to use something else if possible. Would be great if something could be connected to a Bool or the Queue i am using. Here is the Codes:
SharpDX.Windows.RenderLoop.Run(form, () =>
{
if (Queue.TryDequeue(out TextureData))
{
........
}
else
{
AutoReset.WaitOne(100);
}
});
So there it does it´s thing, if there is something in a Queue, else it will wait on AutoReset Up till 100ms (this is to prevent the Form to totally freeze).
while (ReceiveCheck.Checked && tt1.Connected)
{
...........
AutoReset.Set();
Queue.Enqueue(tempBytes);
}
And there i simply do my work, and then tell the other thread to start, and right after i Queue my item. (why i AutoReset Before that is because of the delay, to help minimize it a bit).
Is there a way to improve this? Would be great if the other thread could just wait until there is something in the Queue and then run.