I would use the async await
framework to run the tests asynchronously.
Code a Device
class that is able to run the TestDevice
method asynchronously. Something like.
public class Device
{
public async Task<Data[]> TestDeviceAsync()
{
return await Task.Run(() => TestDevice());
}
private Data[] TestDevice()
{
return new Data[6];
}
}
Then instantiate a TestManager
class to run the required tests.
public class TestManager
{
public async Task TestDevicesAsync()
{
var tasks = new List<Task<Data[]>>();
for (int i = 0; i < 6; i++)
{
var device = new Device();
Task<Data[]> task = device.TestDeviceAsync();
tasks.Add(task);
}
Data[][] testResults = await Task.WhenAll(tasks);
foreach (var dataArry in testResults)
{
}
}
}