Nested Parallel.ForEach loops

前端 未结 2 1749
说谎
说谎 2020-12-20 10:52

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

2条回答
  •  攒了一身酷
    2020-12-20 11:40

    The answer will be, it depends;

    1. What are you doing with the IP address once you have it?
    2. How long does each step take?

    Threads are not cheap, they take time to create, and memory to exist. If you're not doing something computationally expensive with those IP Addresses, and using the wrong type of collection for concurrent access, you're almost certainly slowing down your application.

    Use StopWatch to help you answer these questions.

提交回复
热议问题