473,836 Members | 1,518 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cant put a wait on external application?

11 New Member
Hello all,

I have problems letting this application wait. I tried everything in my knowledge.
Here is the code:

Expand|Select|Wrap|Line Numbers
  1.                     System.Diagnostics.Process procdemux = new System.Diagnostics.Process();
  2.                     procdemux.StartInfo.UseShellExecute = true;
  3.                     procdemux.StartInfo.CreateNoWindow = false;
  4.                     procdemux.StartInfo.RedirectStandardOutput = false;
  5.                     procdemux.StartInfo.FileName = currentPath + "\\res\\demux.bat";
  6.                     procdemux.Start();
  7.                     procdemux.WaitForExit(3000);
  8.                     procdemux.Close();
  9.  
this code follows it up:

Expand|Select|Wrap|Line Numbers
  1.             System.Diagnostics.Process procencode = new System.Diagnostics.Process();
  2.             procencode.StartInfo.UseShellExecute = true;
  3.             procencode.StartInfo.CreateNoWindow = false;
  4.             procencode.StartInfo.RedirectStandardOutput = false;
  5.             procencode.StartInfo.FileName = currentPath + "\\res\\encode.bat";
  6.             procencode.Start();
  7.             procencode.WaitForExit(3000);
  8.             procencode.Close(); 
  9.  
Can someone please help me?

Thanks in advance!

Regards,

Dennis
Jun 4 '07
12 1445
TRScheel
638 Recognized Expert Contributor
You can put a thread.sleep(#) in the loop to lessen the CPU load of sitting there just looping. Something like 100, or 250, shouldnt be too noticable.
Jun 26 '07 #11
blackjack2150
79 New Member
Here's another idea:

Do a while loop in which you check to see that the process you started is still running. If not, break out of the loop and continue on else loop again.
This way you don't have to guess how long it will take.

The Process class has all you need for this.
Jun 27 '07 #12
TRScheel
638 Recognized Expert Contributor
Here's another idea:

Do a while loop in which you check to see that the process you started is still running. If not, break out of the loop and continue on else loop again.
This way you don't have to guess how long it will take.

The Process class has all you need for this.
I fooled around with the process.HasExit ed but the problem exists that the program might just sit there doing nothing. Its threadstate gets stuck at unknown, wait, or something else. What's it doing? Waiting for user input? Printing? Done? Its a tough issue to take up depending on the program you are using.
Jun 27 '07 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2003
by: S. van Beek | last post by:
Dear reader, In case an application is ussing an external model library you have to address this external model library in your application. This addressing takes place in a module of the application by opening of a module and activates and than brows to the location of the external library.
4
17085
by: Peter | last post by:
I am using CreateProcessWithLogonW to run an external application, the problem I am having is that the C# program does not wait until the external program finishes running before continuing. The external program is a console application and it does not interact with users, how can I make my C# program wait until the program initiated by CreateProcessWithLogonW API completes running before continuing? here's my API code. bool ret =...
4
2558
by: Terry Brown | last post by:
I am trying to use WaitForExit to determine when an external application I have launched has exited (duh!). I found examples everywhere and it seemed simple and this works perfectly: Dim myProcess As Process = _ System.Diagnostics.Process.Start("notepad.exe") ' wait until it exits myProcess.WaitForExit()
5
3654
by: snicks | last post by:
I'm trying to exec a program external to my ASP.NET app using the following code. The external app is a VB.NET application. Dim sPPTOut As String sPPTOut = MDEPDirStr + sID + ".ppt" Dim p As New System.Diagnostics.Process 'p.Start(MDEPDirStr & "macrun.exe", sPPTOut) p.Start("C:\WINDOWS\SYSTEM32\CALC.EXE") 'p.Start("C:\WINDOWS\SYSTEM32\macrun.exe", sPPTOut)
1
1920
by: Divyesh | last post by:
Hello, I need to call external application from my C# application. I can use Process.Start(<FileName>) for that but I also need to wait for that application to finish before I process. Any clue? Rgds, Divyesh
0
1715
by: NvrBst | last post by:
I want to send a bunch of keys to an external window using PostMessage. I send a "KEYDOWN" message (then have to wait for the program to produce the CHAR message) then send the "KEYUP" message. Sometimes I have to only wait 1ms, others I have to wait up to 10ms. Always waiting 10ms for the long messages makes the typing looks slower... Is there a way to find out when the "CHAR" message was processed in the external window? IE, If I...
5
1868
by: Nayan | last post by:
Hi, If I make a call to function which is in external library, and it goes into wait sate.. disabling my app to proceed further, how can I break this state elegantly? So far, I had to kill my process. Someone suggested to code multi-threaded app in which one can monitor other and if one goes into locked state, other kills it. It sounds okay, but I don't know how to do it. Any code sample or
1
5627
by: Gunnar G | last post by:
If I wish to run an external application with exec(), does the execution of the PHP script halt until the external application has finished?
1
1615
by: JasonT | last post by:
Hi. I have created a dll in VC++ 08 that exports a CLR windows form class. I call into this dll from an external (closed source, third-party) application to instantiate the form and embed it into the external application window using SetParent(). The problem is, the form runs in the external application window, but the external application no longer updates (renders, responds to close button click, etc.). Now I know the reason is that in...
0
9826
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10860
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10604
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9389
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6984
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5831
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4026
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3116
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.