Process Fails while calling Start

  • Thread starter Thread starter Anbu
  • Start date Start date
A

Anbu

Hi all,

I'm creating processes of a console based application. After
proc.Start() the process is not getting terminated and the thread
keeps waiting for some reponse from the process. Now I need to kill
the process if it takes more time.

Process proc = new Process();

proc.StartInfo.FileName = "application";
proc.StartInfo.WorkingDirectory = workingdir;
proc.StartInfo.Arguments = " args1 arg2";
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
logger.Debug("Parameters used : " + proc.StartInfo.Arguments);
proc.Start();
proc.WaitForExit();
proc.Dispose();

The process is started when the control reaches proc.Start(). Hope the
control should move to the next statement proc.WaitForExit() and wait
until the process gets completed. The control is not moving out of the
statement.

When I look at the threads from .NET IDE, I could see a thread still
active for this call. No further execution is allowed from this point.
Any clue why this is failing?

How can I do this? Otherwise I need to terminate those threads if
running for more time.

Thanks
 
Hi all,

I'm creating processes of a console based application. After
proc.Start() the process is not getting terminated and the thread
keeps waiting for some reponse from the process. Now I need to kill
the process if it takes more time.

Process proc = new Process();

proc.StartInfo.FileName = "application";
proc.StartInfo.WorkingDirectory = workingdir;
proc.StartInfo.Arguments = " args1 arg2";
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
logger.Debug("Parameters used : " + proc.StartInfo.Arguments);
proc.Start();
proc.WaitForExit();
proc.Dispose();

The process is started when the control reaches proc.Start(). Hope the
control should move to the next statement proc.WaitForExit() and wait
until the process gets completed. The control is not moving out of the
statement.

When I look at the threads from .NET IDE, I could see a thread still
active for this call. No further execution is allowed from this point.
Any clue why this is failing?

How can I do this? Otherwise I need to terminate those threads if
running for more time.

Thanks

I'm not very sure about your situation, but perhaps you can try
multithreading. Create another thread that remains in control even
though this thread this waiting. When this thread launches the
process, the other thread is notified and should wait for some time,
if it takes too long, it terminates the process.
 
Anbu said:
Hi all,

I'm creating processes of a console based application. After
proc.Start() the process is not getting terminated and the thread
keeps waiting for some reponse from the process. Now I need to kill
the process if it takes more time.

Process proc = new Process();

proc.StartInfo.FileName = "application";
proc.StartInfo.WorkingDirectory = workingdir;
proc.StartInfo.Arguments = " args1 arg2";
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
logger.Debug("Parameters used : " + proc.StartInfo.Arguments);
proc.Start();
proc.WaitForExit();
proc.Dispose();

The process is started when the control reaches proc.Start(). Hope the
control should move to the next statement proc.WaitForExit() and wait
until the process gets completed. The control is not moving out of the
statement.

When I look at the threads from .NET IDE, I could see a thread still
active for this call. No further execution is allowed from this point.
Any clue why this is failing?

How can I do this? Otherwise I need to terminate those threads if
running for more time.

Thanks



Why starting a new thread while this same question has been answered in another thread of
yours?

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top