Link to home
Start Free TrialLog in
Avatar of Ron Kidd
Ron KiddFlag for Australia

asked on

Loop through Multiple Processes Async

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

ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada 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
Avatar of Ron Kidd

ASKER

Perfect

Thanks very much for that