S
Sudip_inn
Guest
see my code. which has 3 Parallel.ForEach. i want when first inner Parallel.ForEach will execute to populate brokerRowWeightageRowNumber then at end it will pass row number to block where i will populate ConsensusRowWeightageRowNumber and after that last nested Parallel.ForEach will execute which will populate QcRowWeightageRowNumber
how to achieve for my scenario using Parallel.ForEach loop with partition-local variables. thanks
Parallel.ForEach(OrderWiseLineItem, data =>
{
// string Li = data1.LineItem;
string section = data.Section;
string Li = data.Lineitem;
if (!String.IsNullOrEmpty(Li) && !String.IsNullOrEmpty(section))
{
Parallel.ForEach(DistinctBroker, broker =>
{
// for broker row .... weightage 1 (no color)
Interlocked.Increment(ref rowNumber);
brokerRowWeightageRowNumber = new WeightageRowNumber();
brokerRowWeightageRowNumber.Section = section;
brokerRowWeightageRowNumber.Lineitem = Li;
brokerRowWeightageRowNumber.Broker = broker;
brokerRowWeightageRowNumber.RowNumber = rowNumber;
brokerRowWeightageRowNumber.Weightage = (int)RowWeightage.BrokerRow;
lock (_lock)
{
WeightageRowNumberall.Add(brokerRowWeightageRowNumber);
}
}
Interlocked.Increment(ref rowNumber);
ConsensusRowWeightageRowNumber = new WeightageRowNumber();
ConsensusRowWeightageRowNumber.Section = section;
ConsensusRowWeightageRowNumber.Lineitem = Li;
ConsensusRowWeightageRowNumber.Broker = "";
ConsensusRowWeightageRowNumber.RowNumber = rowNumber;
ConsensusRowWeightageRowNumber.Weightage = (int)RowWeightage.ConsenSusRow;
lock (_lock)
{
WeightageRowNumberall.Add(ConsensusRowWeightageRowNumber);
}
if (qcTrueDistin.Any(x => x.TabName.Equals(section) && x.StandardLineItem.Equals(Li)))
{
// for QC Check row .... weightage 3, if any (yellow color)
Parallel.ForEach(DistinctBroker, broker =>
{
Interlocked.Increment(ref rowNumber);
QcRowWeightageRowNumber = new WeightageRowNumber();
QcRowWeightageRowNumber.Section = section;
QcRowWeightageRowNumber.Lineitem = Li;
QcRowWeightageRowNumber.Broker = broker;
QcRowWeightageRowNumber.RowNumber = rowNumber;
QcRowWeightageRowNumber.Weightage = (int)RowWeightage.QcRow;
lock (_lock)
{
WeightageRowNumberall.Add(QcRowWeightageRowNumber);
}
}
}
}
}
Continue reading...
how to achieve for my scenario using Parallel.ForEach loop with partition-local variables. thanks
Parallel.ForEach(OrderWiseLineItem, data =>
{
// string Li = data1.LineItem;
string section = data.Section;
string Li = data.Lineitem;
if (!String.IsNullOrEmpty(Li) && !String.IsNullOrEmpty(section))
{
Parallel.ForEach(DistinctBroker, broker =>
{
// for broker row .... weightage 1 (no color)
Interlocked.Increment(ref rowNumber);
brokerRowWeightageRowNumber = new WeightageRowNumber();
brokerRowWeightageRowNumber.Section = section;
brokerRowWeightageRowNumber.Lineitem = Li;
brokerRowWeightageRowNumber.Broker = broker;
brokerRowWeightageRowNumber.RowNumber = rowNumber;
brokerRowWeightageRowNumber.Weightage = (int)RowWeightage.BrokerRow;
lock (_lock)
{
WeightageRowNumberall.Add(brokerRowWeightageRowNumber);
}
}
Interlocked.Increment(ref rowNumber);
ConsensusRowWeightageRowNumber = new WeightageRowNumber();
ConsensusRowWeightageRowNumber.Section = section;
ConsensusRowWeightageRowNumber.Lineitem = Li;
ConsensusRowWeightageRowNumber.Broker = "";
ConsensusRowWeightageRowNumber.RowNumber = rowNumber;
ConsensusRowWeightageRowNumber.Weightage = (int)RowWeightage.ConsenSusRow;
lock (_lock)
{
WeightageRowNumberall.Add(ConsensusRowWeightageRowNumber);
}
if (qcTrueDistin.Any(x => x.TabName.Equals(section) && x.StandardLineItem.Equals(Li)))
{
// for QC Check row .... weightage 3, if any (yellow color)
Parallel.ForEach(DistinctBroker, broker =>
{
Interlocked.Increment(ref rowNumber);
QcRowWeightageRowNumber = new WeightageRowNumber();
QcRowWeightageRowNumber.Section = section;
QcRowWeightageRowNumber.Lineitem = Li;
QcRowWeightageRowNumber.Broker = broker;
QcRowWeightageRowNumber.RowNumber = rowNumber;
QcRowWeightageRowNumber.Weightage = (int)RowWeightage.QcRow;
lock (_lock)
{
WeightageRowNumberall.Add(QcRowWeightageRowNumber);
}
}
}
}
}
Continue reading...