KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm running a Parallel.For loop on a little over 7500 objects. Inside that for loop, I'm doing a number of things to each of those objects, specifically calling two web services and two internal methods. The web services simply inspect the object, process and return a string that i then set as a property on the object. Same goes for the two internal methods. I'm not writing anything out to disk or reading from disk. I also update the UI in a winforms app with a label and progress bar to let the user know where it's at. Here's the code: var task = Task.Factory.StartNew(() => { Parallel.For(0, upperLimit, (i, loopState) => { if (cancellationToken.IsCancellationRequested) loopState.Stop(); lblProgressBar.Invoke( (Action) (() => lblProgressBar.Text = string.Format("Processing record {0} of {1}.", (progressCounter++), upperLimit))); progByStep.Invoke( (Action) (() => progByStep.Value = (progressCounter - 1))); CallSvc1(entity[i]); Conversion1(entity[i]); CallSvc2(entity[i]); Conversion2(entity[i]); }); }, cancellationToken); This is taking place on a Win7 32bit machine. Any ideas as to why this suddenly freezes when the incrementer is around 1370 or so (It's been 1361, 1365 and 1371)? Any ideas as to how I can debug this and see what's locking if anything? EDIT: Some answers to the comments below: @BrokenGlass - No, no interop. I'll try the x86 compilation and let you know. @chibacity - Because it's on a background task, it's not freezing the UI. Up until the time it freezes, the progress bar and label tick along at about 2 every second. When it freezes, it just stops moving. I can verify that the number that it stops at has been processed, but no more. CPU usage on a dual core 2.2GHz is minimal during the operation at 3-4% each and 1-2% once it freezes. @Henk Ho
Tags (comma-separated)
Save Edits
Cancel