parallel.foreach Questions

13

Solved

I'm going to use lots of tasks running on my application. Each bunch of tasks is running for some reason. I would like to name these tasks so when I watch the Parallel Tasks window, I could recogni...
Pula asked 7/12, 2012 at 11:34

7

I am trying to execute parallel functions on a list of objects using the new C# 4.0 Parallel.ForEach function. This is a very long maintenance process. I would like to make it execute in the order ...
Erection asked 3/9, 2010 at 21:46

2

Why Parallel.ForEach loop exits with OperationCancelledException, while using GetConsumableEnumerable? //outside the function static BlockingCollection<double> _collection = new BlockingColle...

4

Solved

Erg, I'm trying to find these two methods in the BCL using Reflector, but can't locate them. What's the difference between these two snippets? A: IEnumerable<string> items = ... Parallel.F...

3

Solved

I am porting some code to Parallel.ForEach and got an error with a continue I have in the code. Is there something equivalent I can use in a Parallel.ForEach functionally equivalent to continue in ...

6

Solved

Here is the code: using (var context = new AventureWorksDataContext()) { IEnumerable<Customer> _customerQuery = from c in context.Customers where c.FirstName.StartsWith("A") select c; v...
Bespangle asked 17/5, 2011 at 19:32

5

Solved

I have a Parallel.ForEach() async loop with which I download some webpages. My bandwidth is limited so I can download only x pages per time but Parallel.ForEach executes whole list of desired webpa...
Vagrant asked 15/2, 2012 at 9:8

3

Solved

I have some code which I am currently optimizing for concurrency in multicore architectures. In one of my classes, I found a nested foreach loop. Basically the outer loop iterates through an array ...

1

I'm using Parallel.ForEach and it's hugely improving the performance of my code, but I'm curious about DbContext with multiple threads. I know it's not thread safe so I'm using locks where I need t...

1

Solved

I observed a strange behavior while experimenting with the Parallel.ForEach method and the BlockingCollection<T> class. Apparently calling the two lines below on a separate thread, is enough ...

2

I am processing PDFs of vastly varying sizes (simple 2MB to high DPI scans of a few hundred MB) via a Parallel.ForEach and am occasionally getting to an OutOfMemoryException - understandably due to...

6

Solved

Given this code: var arrayStrings = new string[1000]; Parallel.ForEach<string>(arrayStrings, someString => { DoSomething(someString); }); Will all 1000 threads spawn almost simultaneou...

4

Solved

I've already read previous questions here about ConcurrentBag but did not find an actual sample of implementation in multi-threading. ConcurrentBag is a thread-safe bag implementation, optimized...

6

Solved

I am using Parallel.ForEach and I am doing some database updates, now without setting MaxDegreeOfParallelism, a dual core processor machine results in SQL client timeouts, where else quad core proc...

4

Solved

Essentially, I am working with this: var data = input.AsParallel(); List<String> output = new List<String>(); Parallel.ForEach<String>(data, line => { String outputLine = ""...

0

I am using the AsyncEnumerator library by @Serge Semenov, and after getting the orders, creating the ConcurrentBag and setting count to 0, nothing happens - can anyone see what's missing here? It n...

5

Solved

I understand that the new TPL (Task Parallel Library) has implemented the Parallel.ForEach such that it works with "expressed parallelism." This means it does not guarantee that your dele...

3

Solved

Is Parallel.ForEach() with MaxDegreeOfParallelism==1 guaranteed to process the input enumerable in-order? If the answer is "no", is there a way to enforce this behavior?
Ratchford asked 15/3, 2017 at 13:42

8

Solved

Is there an easy way to step through a parallel.foreach? What is the best way to debug this with a break point?
Copenhagen asked 19/6, 2012 at 20:35

3

I am running a multi-threaded loop: protected ParallelOptions parallelOptions = new ParallelOptions(); parallelOptions.MaxDegreeOfParallelism = 2; Parallel.ForEach(items, parallelOptions, item =&g...

4

Solved

I have a Parallel.ForEach loop doing some treatment. But the first operation is to add a value in the dictionary if the key is not contained. I get an error when adding it, it says that the key is ...
Jevons asked 1/4, 2014 at 15:37

1

Solved

I'm actually facing a problem with parallelism on asynchronous tasks. My goal is to have an async Task which connects to multiple endpoints to retrieve the same kind of data. A list with all "...

6

Solved

I'm calling a slow webservice in parallel. Things were great until I realized I need to get some information back from the service. But I don't see where to get the values back. I can't write to th...
Readability asked 26/9, 2012 at 21:39

2

Solved

In C#, I am interested in stopping a Parallel.ForEachAsync loop (considering the differences between Stop and Break); for Parallel.ForEach I can do the following: Parallel.ForEach(items, (item, sta...

4

Solved

And by "same thing" I mean do these two operations basically do the same work, and it just boils down to which one is more convenient to call based on what you have to work with? (i.e. a ...

© 2022 - 2025 — McMap. All rights reserved.