Link to home
Start Free TrialLog in
Avatar of rutledgj
rutledgj

asked on

Another Parallel programming question VB.NET

So with your help I now have this working

  Dim w As New Work
            Parallel.ForEach(LstVendors, Sub(currentVendor)
                                             'Dim w As New Work
                                             w.DoWork(currentVendor)
                                         End Sub)

What I really need now is a way to :
1 Use a queue to process,
2. Have a cancellation token available
3. Have a way to know when all tasks are completed.

Please only vb.net code.  I can find csharp examples but have a very hard time converting them to vb.
Avatar of nepaluz
nepaluz
Flag of United Kingdom of Great Britain and Northern Ireland image

re-write your Work class a backgroundworker class and utilize the backgroundworker's cancellation and completed events to fulfill 2 and 3 above. here's a good Microsoft walthrough
http://msdn.microsoft.com/en-us/library/ywkkz4s1.aspx
Avatar of rutledgj
rutledgj

ASKER

I was looking more for a way to use the task.waitall method
It appears that waitall requires a list of task to monitor which I don't see a way to do that using the foreach loop. Is there another way to do this not using foreach where the tasks can be saved to a collection?
ASKER CERTIFIED SOLUTION
Avatar of nepaluz
nepaluz
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok. So what I have is a class Vendor.

I have a LstVendor(of Vendor)

I have another class called Worker with a method called DoWork(v as Vendor)

I'm not sure how to substitute my  items into your code where Object is.
your class Worker is in this case replaced by the vendorsAction function. So I would just copy the DoWork method in there to the function.