Solved

calling a process (external) in a loop

Posted on 2009-07-14
4
154 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

746 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

12 Experts available now in Live!

Get 1:1 Help Now