In my C# program, I have got method code:
Object model;
int score;
for()
{
int tempScore=0;
Object tempModel=getModel();
//some interesting stuff modifying value of tempScore
if(tempScore>score)
{
score=tempScore;
model=tempModel;
}
}
I would like to use Parallel for insted of normal, but I'm afraid that i will encounter some synchronization issues. I know that I can use lock(model), but what can I do about simple type score? model and score are method local variables, therefore they are shared between threads.