c# - How to loop xmlnodes in parallel -


i have following code:

foreach (xmlnode xn in xnlist) { string name = xn["name"].innertext; } 

i want launch each loop in parallel. how can this? thought use following method, can't figure out way make work:

 paralleloptions paroptions = new paralleloptions(); paroptions.maxdegreeofparallelism = 4; //only 5 threads allowed. parallel.foreach(xnlist.asenumerable(), paroptions, xn=> { string name = xn["name"].innertext; } 

what tried done below:

parallel.foreach(xnlist.asenumerable(), item=>{string name = item["name"].innertext;}); 

but if using winform , want processes , preventing waiting cursor, problem.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -