?
Solved

Loop through Multiple Processes Async

Posted on 2016-11-23
2
Medium Priority
?
60 Views
Last Modified: 2016-11-24
Hello

I have a Program that needs to Generate pdf files (Invoices) for emailing.
I can have up to 50 pdf files to Generate per Email.
I want to loop through all the Files and Generate 5 Async until all files are generated.
i.e. I want 5 pdf files being generated continually until all the files have been generated. (As soon as one finishes I want another one to start - Keeping 5 Being generated)

How do I do this?

Currently I have the Below.

Dim fileList As New List(Of String)

        ' Code to Populate List

        For Each item In fileList
            'Generate PDF of Order
            Dim processToStart As New ProcessStartInfo
            processToStart.FileName = "C:\PDFProgram.exe"
            processToStart.Arguments = item
            processToStart.UseShellExecute = False
            Process.Start(processToStart).WaitForExit()
        Next

Open in new window

0
Comment
Question by:p-plater
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 2000 total points
ID: 41900363
you can use parallel.foreach as shown in https://msdn.microsoft.com/en-us/library/dd460720(v=vs.110).aspx
0
 

Author Closing Comment

by:p-plater
ID: 41900956
Perfect

Thanks very much for that
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question