I need to perform two parallel tasks multiple times in a .NET 3.5/C#/WPF program.
In my case, the tasks perform some calculation on data provided by a device (Kinect). So each time new data are received I need to start two tasks doing different computation.
I am using Thread
for each task and when I receive new data I recreate each thread with a new
statement.
// Data received
task1 = new Thread(new ThreadStart(ExtractData1));
task2 = new Thread(new ThreadStart(ExtractData2));
Everything is working correctly, but my question is about efficiency. I am wondering if there is a better way to accomplish this...
Should I keep using Thread
like this ?
Is there a performance hit to recreate the Thread
each time ?
Should I create the Thread
only once and use ManualResetEvent
to trigger the computation ?
Thanks in advance.