Avatar of 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
                                         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

8/22/2022 - Mon

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

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?
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

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.