Click here to Skip to main content
15,895,656 members
Home / Discussions / C#
   

C#

 
AnswerRe: Socket Exception Pin
Pete O'Hanlon6-Apr-11 6:06
mvePete O'Hanlon6-Apr-11 6:06 
GeneralRe: Socket Exception Pin
Paul Harsent6-Apr-11 6:09
Paul Harsent6-Apr-11 6:09 
GeneralRe: Socket Exception Pin
Pete O'Hanlon6-Apr-11 6:21
mvePete O'Hanlon6-Apr-11 6:21 
GeneralRe: Socket Exception Pin
#realJSOP6-Apr-11 9:07
mve#realJSOP6-Apr-11 9:07 
GeneralRe: Socket Exception Pin
Pete O'Hanlon6-Apr-11 9:13
mvePete O'Hanlon6-Apr-11 9:13 
GeneralRe: Socket Exception Pin
ankitjoshi246-Apr-11 9:40
ankitjoshi246-Apr-11 9:40 
AnswerRe: Socket Exception Pin
Luc Pattyn6-Apr-11 6:57
sitebuilderLuc Pattyn6-Apr-11 6:57 
GeneralParallel.For Issue Pin
Bassam Abdul-Baki6-Apr-11 5:12
professionalBassam Abdul-Baki6-Apr-11 5:12 
I have a program that I'm trying to multithread. It works correctly on a single processor. All I had to do was change the for loop to Parallel.For and add ");" at the end. Basically, the structure is as follows:
Variables (V) that do not get modified inside the loop, including a LinkedList<BigInteger> that does.

Parallel.For (0, 5, j => {
  BigInteger Variable that relies on j and another from (V - outside loop).
  foreach (BigInteger k in numbers) {
    Local Variables.
    //Console.WriteLine(Everything in numbers.);     if (condition)
    {
      Add k to LinkedList.
      Console.WriteLine(k and other data.);
    }
  Console.WriteLine(Summary count per loop.);
});
This parallel loop is missing a few values when multithreaded. However, if I put a write statement just before the IF to capture everything (commented out), it works. The summary count comes up accurate every time.  If I comment it out, it fails, every time starting at higher values of k across all j.  Basically, it starts working and slowly degrades. It seems to be that the write statement is slowing it down for it to work.

Do I need a more threaded way of adding to the LinkedList array or am I missing something else? Any suggestions would be appreciated.

NB - Can't submit code and this is console programming without the use of Visual Studio. Don't ask! Smile | :)

GeneralRe: Parallel.For Issue Pin
David19876-Apr-11 5:19
David19876-Apr-11 5:19 
GeneralRe: Parallel.For Issue Pin
Bassam Abdul-Baki6-Apr-11 5:25
professionalBassam Abdul-Baki6-Apr-11 5:25 
AnswerRe: Parallel.For Issue Pin
Luc Pattyn6-Apr-11 5:25
sitebuilderLuc Pattyn6-Apr-11 5:25 
GeneralRe: Parallel.For Issue Pin
Bassam Abdul-Baki6-Apr-11 5:29
professionalBassam Abdul-Baki6-Apr-11 5:29 
GeneralRe: Parallel.For Issue Pin
David19876-Apr-11 5:31
David19876-Apr-11 5:31 
GeneralRe: Parallel.For Issue Pin
Luc Pattyn6-Apr-11 6:32
sitebuilderLuc Pattyn6-Apr-11 6:32 
GeneralRe: Parallel.For Issue Pin
BobJanova6-Apr-11 6:31
BobJanova6-Apr-11 6:31 
GeneralRe: Parallel.For Issue Pin
AspDotNetDev6-Apr-11 7:07
protectorAspDotNetDev6-Apr-11 7:07 
GeneralRe: Parallel.For Issue Pin
Bassam Abdul-Baki6-Apr-11 14:13
professionalBassam Abdul-Baki6-Apr-11 14:13 
GeneralRe: Parallel.For Issue Pin
Luc Pattyn6-Apr-11 5:24
sitebuilderLuc Pattyn6-Apr-11 5:24 
GeneralRe: Parallel.For Issue Pin
Bassam Abdul-Baki6-Apr-11 5:27
professionalBassam Abdul-Baki6-Apr-11 5:27 
AnswerRe: Parallel.For Issue Pin
Luc Pattyn6-Apr-11 5:36
sitebuilderLuc Pattyn6-Apr-11 5:36 
GeneralRe: Parallel.For Issue Pin
Bassam Abdul-Baki6-Apr-11 5:40
professionalBassam Abdul-Baki6-Apr-11 5:40 
GeneralRe: Parallel.For Issue Pin
Mirko19806-Apr-11 10:21
Mirko19806-Apr-11 10:21 
GeneralRe: Parallel.For Issue Pin
Bassam Abdul-Baki6-Apr-11 14:14
professionalBassam Abdul-Baki6-Apr-11 14:14 
QuestionRundom function Pin
treuveni6-Apr-11 4:48
treuveni6-Apr-11 4:48 
AnswerRe: Rundom function Pin
PIEBALDconsult6-Apr-11 4:53
mvePIEBALDconsult6-Apr-11 4:53 

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.