Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - Console application hangs when called from Process.Start

 
Thread Tools Search this Thread
Old 04-06-2006, 09:29 PM   #1
Default Console application hangs when called from Process.Start


Hi,

I am using Process.Start() to call a console application from ASP.NET
page. When the code is executed, the Console application is opened.
When it is done, it should have been terminated but it is not. I have
placed WaitForExit(20000) to limit the execution time to 20 seconds and
if it does not terminate then it will be forced close. The question is
why wouldn't the application exit by itself when it is done as it
should be (it was idle). Please see the code below.

System.Diagnostics.ProcessStartInfo processInfo = new
System.Diagnostics.ProcessStartInfo(path, parameters);
processInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
processInfo.RedirectStandardOutput = true;
processInfo.UseShellExecute = false;
processInfo.CreateNoWindow = true;

System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo = processInfo;
process.Start();
process.WaitForExit(20000);
process.Kill();


Thanks!!



chad
  Reply With Quote
Old 04-06-2006, 10:42 PM   #2
wfairl@gmail.com
 
Posts: n/a
Default Re: Console application hangs when called from Process.Start
You're redirecting the output so you're going to have to read from the
output stream or the process will hang once it fills (I don't remember
offhand how many bytes it can buffer). If you're doing this in .net 1
you're going to have to poll the stream from another thread, in 2.0 you
can use BeginOutputReadLine instead.



wfairl@gmail.com
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to open Web Application pages (ASPX) in Windows application. arameshmca Software 1 02-07-2008 03:18 AM
I AM THRU WITH DVDPLANET!!!!!!! J. Alfred Prufrock DVD Video 21 10-13-2003 11:56 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46