I have an array of BlockingCollections that i have initiated like this:
BlockingCollection<FxDataMapper>[] _fxDataByPair ;
arrayOfBlockingCollection = new BlockingCollection<MyClassInstance>[4];
for (int i = 0; i < 4; i++)
_arrayOfBlockingCollection[i] = new BlockingCollection<MyClassInstance>();
Now it want to iterate the array and extract each of the array elements and consume the BlockingCollections elements My code is this and although it works i think its not the best one
private void testArrayConsuming()
{
Task processor = Task.Factory.StartNew(() =>
{
foreach (var x in arrayOfBlockingCollection )
{
Task processor2 = Task.Factory.StartNew(() =>
{
foreach (var y in x.GetConsumingEnumerable())
Console.WriteLine(x.Element.Value.ToString());
});
}
});
}