Now that I don't use a Client class and generate the object dynamically, how do I use Parallel.ForEach feature to process multiple clients in the Dynamic Object concurrently as I used to do before using the class object?
First, keep your list as a List<T>
, and don't declare it as dynamic
:
List<dynamic> clients = new List<dynamic>();
Then you can process them the same way:
Parallel.ForEach(clients, client =>
{
// Use client as needed here...
});
If you must leave clients
declared as dynamic clients
, you can use:
Parallel.ForEach((IEnumerable<dynamic>)clients, client =>
{
//...