Click here to Skip to main content
15,885,278 members
Home / Discussions / C#
   

C#

 
GeneralRe: Safe Parallel loops Pin
tvbarnard20-Oct-09 22:44
tvbarnard20-Oct-09 22:44 
GeneralRe: Safe Parallel loops Pin
stancrm20-Oct-09 22:55
stancrm20-Oct-09 22:55 
GeneralRe: Safe Parallel loops Pin
tvbarnard20-Oct-09 23:06
tvbarnard20-Oct-09 23:06 
AnswerRe: Safe Parallel loops [modified] Pin
Hristo-Bojilov20-Oct-09 22:38
Hristo-Bojilov20-Oct-09 22:38 
GeneralRe: Safe Parallel loops Pin
tvbarnard20-Oct-09 22:45
tvbarnard20-Oct-09 22:45 
GeneralRe: Safe Parallel loops Pin
Hristo-Bojilov20-Oct-09 23:55
Hristo-Bojilov20-Oct-09 23:55 
GeneralRe: Safe Parallel loops Pin
tvbarnard20-Oct-09 22:47
tvbarnard20-Oct-09 22:47 
GeneralRe: Safe Parallel loops Pin
tvbarnard20-Oct-09 22:58
tvbarnard20-Oct-09 22:58 
Reason why i'm asking for an example is that I already tried my own method of locking, but my data still got corrupted.

This is the type of code I used...
List<int[,]> largeData; //a 5000x500 matrix
List<int[]> referenceList; //each int[] has about 10 elements
int answer;

//loops
Parallel.Foreach<int[]>(referenceList, refArray=>
{
   foreach(int[,] largeMatrix in largeData)
   {
      lock(largeMatrix)
      {
         answer = 0;

         foreach(int ref in refArray)
         {
            answer += largeMatrix[ref];         
         }
         
         //use "answer" for more processing here
      }
   }
});


I also tried locking the "refArray", but in either case, I got the wrong results...

tvb

GeneralRe: Safe Parallel loops Pin
Luc Pattyn21-Oct-09 2:47
sitebuilderLuc Pattyn21-Oct-09 2:47 
GeneralRe: Safe Parallel loops Pin
tvbarnard21-Oct-09 3:06
tvbarnard21-Oct-09 3:06 
QuestionEmbed image to an e-mail and not a link… Pin
anderslundsgard20-Oct-09 21:27
anderslundsgard20-Oct-09 21:27 
AnswerRe: Embed image to an e-mail and not a link… Pin
Christian Graus20-Oct-09 21:42
protectorChristian Graus20-Oct-09 21:42 
AnswerRe: Embed image to an e-mail and not a link… Pin
Giorgi Dalakishvili20-Oct-09 23:36
mentorGiorgi Dalakishvili20-Oct-09 23:36 
QuestionProblem in accessing the COM port. "Access denied for COM1 " Pin
pallaka20-Oct-09 21:09
pallaka20-Oct-09 21:09 
AnswerRe: Problem in accessing the COM port. "Access denied for COM1 " Pin
stancrm20-Oct-09 21:24
stancrm20-Oct-09 21:24 
GeneralRe: Problem in accessing the COM port. "Access denied for COM1 " Pin
pallaka20-Oct-09 21:46
pallaka20-Oct-09 21:46 
GeneralRe: Problem in accessing the COM port. "Access denied for COM1 " Pin
stancrm20-Oct-09 22:28
stancrm20-Oct-09 22:28 
GeneralRe: Problem in accessing the COM port. "Access denied for COM1 " Pin
pallaka20-Oct-09 22:30
pallaka20-Oct-09 22:30 
GeneralRe: Problem in accessing the COM port. "Access denied for COM1 " Pin
stancrm20-Oct-09 22:34
stancrm20-Oct-09 22:34 
GeneralRe: Problem in accessing the COM port. "Access denied for COM1 " Pin
pallaka20-Oct-09 22:40
pallaka20-Oct-09 22:40 
GeneralRe: Problem in accessing the COM port. "Access denied for COM1 " Pin
stancrm20-Oct-09 22:49
stancrm20-Oct-09 22:49 
Question.Net-BroadcastEventWindow.2.0.0. Pin
or or20-Oct-09 20:28
or or20-Oct-09 20:28 
AnswerRe: .Net-BroadcastEventWindow.2.0.0. Pin
stancrm20-Oct-09 20:45
stancrm20-Oct-09 20:45 
AnswerRe: .Net-BroadcastEventWindow.2.0.0. Pin
Hristo-Bojilov21-Oct-09 0:13
Hristo-Bojilov21-Oct-09 0:13 
Questionfailed to open a rowset Pin
haleemasher20-Oct-09 20:12
haleemasher20-Oct-09 20:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.