Solved

Loop through Multiple Processes Async

Posted on 2016-11-23
2
36 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
2 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 500 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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
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 …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

792 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