Solved

Loop through Multiple Processes Async

Posted on 2016-11-23
2
15 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 69

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

707 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now