Solved

calling a process (external) in a loop

Posted on 2009-07-14
4
155 Views
Last Modified: 2013-12-17
Hello group,

I've started writing a code in C# and there is a step that I have to read a directory full of PDF and convert them to Text (using an open source). In fact, I am calling a process within a loop.

I'm worry that would cause issue sometimes or ... any idea or advice will be appreciated.

Regards,

in the loop:

 

{

                    Process p = new Process();

 

                    p.StartInfo.UseShellExecute = false;

                    p.StartInfo.RedirectStandardInput = true;

                    p.StartInfo.RedirectStandardOutput = true;

                    p.StartInfo.FileName = "C:\\test\\pdftotext.exe";

                    p.StartInfo.Arguments =  strPDFIn + " " + strTestOut;

                    p.Start();

 

  }

Open in new window

0
Comment
Question by:akohan
  • 2
  • 2
4 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 24859585
What kind of "advice" do you need?  What kind of problems do you foresee?  Do you need to wait for the process to complete before moving on to the next process?  Does each process work on its own .pdf file and output?
0
 

Author Comment

by:akohan
ID: 25170969


Yes, I need to know how I can make it wait to process 1 gets complete.

Regards,
ak
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 250 total points
ID: 25172659
You can use something like this:

p.WaitForExit();

    -- or --

p.WaitForExit(10000);    // Timeout after 10 seconds.
0
 

Author Comment

by:akohan
ID: 25173792


Thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

863 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

26 Experts available now in Live!

Get 1:1 Help Now