Parallel Foreach loop [on hold]
up vote
-2
down vote
favorite
GetValuesFromDB will fetch values from the DB and return a new object which will have SubStatus.
ProcessCounter is a class that defines SafeCounter for Processed, Passed, Failed and Skipped. The Construction set all of them to 0. scheduler defines the MaxDegreeOfParallelism.
GetValuesFromDB or DbOperation doesn't have any lock keyword.
I don't know what the issue is but some of the 'row' are not processed.
ProcessCounter result = new ProcessCounter();
ParallelOptions options = new ParallelOptions()
{
TaskScheduler = scheduler
};
Parallel.ForEach(GetValuesFromDB(), options, row =>
{
try
{
if (row != null)
{
int newSubStatus = 0;
int currentSubStatus = row.SubStatus;
switch (currentSubStatus)
{
case 1:
newSubStatus = //service call
break;
case 2:
case 3:
newSubStatus = //service call
break;
case 4:
newSubStatus = //service call
break;
case 5:
newSubStatus = //service call
break;
}
if (newSubStatus > 0 && newSubStatus != currentSubStatus)
{
result.Processed++;
DbOperation(newSubStatus);
result.Passed++;
}
}
}
catch (Exception ex)
{
result.Failed++;
}
});
c# task-parallel-library
New contributor
put on hold as off-topic by Heslacher, Sᴀᴍ Onᴇᴌᴀ, Toby Speight, πάντα ῥεῖ, t3chb0t 11 hours ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – Heslacher, Sᴀᴍ Onᴇᴌᴀ, Toby Speight, πάντα ῥεῖ, t3chb0t
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
up vote
-2
down vote
favorite
GetValuesFromDB will fetch values from the DB and return a new object which will have SubStatus.
ProcessCounter is a class that defines SafeCounter for Processed, Passed, Failed and Skipped. The Construction set all of them to 0. scheduler defines the MaxDegreeOfParallelism.
GetValuesFromDB or DbOperation doesn't have any lock keyword.
I don't know what the issue is but some of the 'row' are not processed.
ProcessCounter result = new ProcessCounter();
ParallelOptions options = new ParallelOptions()
{
TaskScheduler = scheduler
};
Parallel.ForEach(GetValuesFromDB(), options, row =>
{
try
{
if (row != null)
{
int newSubStatus = 0;
int currentSubStatus = row.SubStatus;
switch (currentSubStatus)
{
case 1:
newSubStatus = //service call
break;
case 2:
case 3:
newSubStatus = //service call
break;
case 4:
newSubStatus = //service call
break;
case 5:
newSubStatus = //service call
break;
}
if (newSubStatus > 0 && newSubStatus != currentSubStatus)
{
result.Processed++;
DbOperation(newSubStatus);
result.Passed++;
}
}
}
catch (Exception ex)
{
result.Failed++;
}
});
c# task-parallel-library
New contributor
put on hold as off-topic by Heslacher, Sᴀᴍ Onᴇᴌᴀ, Toby Speight, πάντα ῥεῖ, t3chb0t 11 hours ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – Heslacher, Sᴀᴍ Onᴇᴌᴀ, Toby Speight, πάντα ῥεῖ, t3chb0t
If this question can be reworded to fit the rules in the help center, please edit the question.
1
Welcome to Code Review. I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
– Heslacher
12 hours ago
add a comment |
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
GetValuesFromDB will fetch values from the DB and return a new object which will have SubStatus.
ProcessCounter is a class that defines SafeCounter for Processed, Passed, Failed and Skipped. The Construction set all of them to 0. scheduler defines the MaxDegreeOfParallelism.
GetValuesFromDB or DbOperation doesn't have any lock keyword.
I don't know what the issue is but some of the 'row' are not processed.
ProcessCounter result = new ProcessCounter();
ParallelOptions options = new ParallelOptions()
{
TaskScheduler = scheduler
};
Parallel.ForEach(GetValuesFromDB(), options, row =>
{
try
{
if (row != null)
{
int newSubStatus = 0;
int currentSubStatus = row.SubStatus;
switch (currentSubStatus)
{
case 1:
newSubStatus = //service call
break;
case 2:
case 3:
newSubStatus = //service call
break;
case 4:
newSubStatus = //service call
break;
case 5:
newSubStatus = //service call
break;
}
if (newSubStatus > 0 && newSubStatus != currentSubStatus)
{
result.Processed++;
DbOperation(newSubStatus);
result.Passed++;
}
}
}
catch (Exception ex)
{
result.Failed++;
}
});
c# task-parallel-library
New contributor
GetValuesFromDB will fetch values from the DB and return a new object which will have SubStatus.
ProcessCounter is a class that defines SafeCounter for Processed, Passed, Failed and Skipped. The Construction set all of them to 0. scheduler defines the MaxDegreeOfParallelism.
GetValuesFromDB or DbOperation doesn't have any lock keyword.
I don't know what the issue is but some of the 'row' are not processed.
ProcessCounter result = new ProcessCounter();
ParallelOptions options = new ParallelOptions()
{
TaskScheduler = scheduler
};
Parallel.ForEach(GetValuesFromDB(), options, row =>
{
try
{
if (row != null)
{
int newSubStatus = 0;
int currentSubStatus = row.SubStatus;
switch (currentSubStatus)
{
case 1:
newSubStatus = //service call
break;
case 2:
case 3:
newSubStatus = //service call
break;
case 4:
newSubStatus = //service call
break;
case 5:
newSubStatus = //service call
break;
}
if (newSubStatus > 0 && newSubStatus != currentSubStatus)
{
result.Processed++;
DbOperation(newSubStatus);
result.Passed++;
}
}
}
catch (Exception ex)
{
result.Failed++;
}
});
c# task-parallel-library
c# task-parallel-library
New contributor
New contributor
edited 12 hours ago
New contributor
asked 13 hours ago
sam
11
11
New contributor
New contributor
put on hold as off-topic by Heslacher, Sᴀᴍ Onᴇᴌᴀ, Toby Speight, πάντα ῥεῖ, t3chb0t 11 hours ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – Heslacher, Sᴀᴍ Onᴇᴌᴀ, Toby Speight, πάντα ῥεῖ, t3chb0t
If this question can be reworded to fit the rules in the help center, please edit the question.
put on hold as off-topic by Heslacher, Sᴀᴍ Onᴇᴌᴀ, Toby Speight, πάντα ῥεῖ, t3chb0t 11 hours ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – Heslacher, Sᴀᴍ Onᴇᴌᴀ, Toby Speight, πάντα ῥεῖ, t3chb0t
If this question can be reworded to fit the rules in the help center, please edit the question.
1
Welcome to Code Review. I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
– Heslacher
12 hours ago
add a comment |
1
Welcome to Code Review. I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
– Heslacher
12 hours ago
1
1
Welcome to Code Review. I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
– Heslacher
12 hours ago
Welcome to Code Review. I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
– Heslacher
12 hours ago
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
1
Welcome to Code Review. I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
– Heslacher
12 hours ago