By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,479 Members | 988 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,479 IT Pros & Developers. It's quick & easy.

Parallel.Foreach usage

maylortaylor
P: 72
I have a zipping program that reads information from a XML file. The xml file contains the source or each file, the destination for each file, and a title for each 'job'.

I am trying to get the actual zipping process to run on multiple threads using Parallel.ForEach

So far i have (code is shortened for your consideration)
Expand|Select|Wrap|Line Numbers
  1. Dim JobNodes As XmlNodeList = doc.GetElementsByTagName("Job")
  2. For Each JobNode In JobNodes
  3.  
  4. Dim Destin = JobNode.SelectNodes("Destination")
  5.  
  6. Parallel.ForEach(Destin,Sub(item) 
  7. //code to do zipping 
  8. end sub)
I get a HUGE error around the Parallel code. "AmbiguousMatchExeption was unhandled
Expand|Select|Wrap|Line Numbers
  1. Overload resolution failed because no Public 'ForEach' can be called with these arguments:
  2.  
  3.     'Public Shared Function ForEach(Of TSource)(source As OrderablePartitioner(Of TSource), body As Action(Of TSource,ParallelLoopState,Long)) As System.Threading.Tasks.ParallelLoopResult':
  4.  
  5.         Type argument inference fails for argument matching parameter 'source'.
  6.  
  7.         Type argument inference fails for argument matching parameter 'body'.
  8.  
I've never tried to implement multithreading before, so this is all brand new to me. Is there any guidance one of you may bestow upon me?
Feb 19 '13 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.