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.
Visual Basic.NET

Avatar of undefined
Last Comment
nepaluz
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
Avatar of rutledgj
rutledgj

ASKER

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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of rutledgj
rutledgj

ASKER

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.
Avatar of nepaluz
nepaluz
Flag of United Kingdom of Great Britain and Northern Ireland image

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.
Visual Basic.NET
Visual Basic.NET

Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to Visual Basic pre-2002, it is not the same technology,

96K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo