Menu

System.diagnostics.process waitforexit c#

5 Comments

system.diagnostics.process waitforexit c#

This question may seem a little odd but I am attempting to run VS through a process and execute a specific command and I waitforexit. I have thought of running VS in a silent execution I have yet to find a way to do so. System.diagnostics.process have also attempted to see if there is anything being lauched when this occurs compare to when it does not. Well, I attempted to use FindWindow and FindWindowEx along with SendMessage but I was unable to find the correct window handle. But since I know that a Waitforexit Error Reporting Msssage Box will be popping up, I checked to see if it was its own process and it is. The process is dwwin. Watson Win and all I had to do was this to allow myself to get correct the current problem. Substitute the current code block below for system.diagnostics.process WaitForExit statement that I had previously. Code Block for ;. Could you be specific with the error you are receiving? I would like to try that, but it is too much of a hack. I have too many different commands that take different amounts of time 30 seconds to 25 minutes so there is no real time setting that I could place without destroying my performance. How are you using Process to start the program, Process. I then set up a new thread for both the StandardError and StandardOutput. Start thread for st. If redirecting standard error. I translated what System.diagnostics.process could from the Window that pops up Because problem occurs, it ends Microsoft Visual Studio We applying inconvenience, there is no excuse. Thanks again for all of your time. Why are you doing this? You don't own this stream so you shouldn't be closing it. You don't want to close the sIn object until after the application has exited if you're redirecting. If the application writes to standard output or reads from standard input after you've closed either one of those it could cause an exception. I then redirect the input after the proc. Start command, so how do I not own this? Regardless, I can make the change to move the sIn. Close to after the WaitForExit call to see if this makes any changes. Again, it is not an error message, so there is no stack trace. My StandardError redirection is empty and the Standard OUtput redirection contains what I expected, but nothing indicating an error occurred. I will post what happens after I move the sIn. Close line below the WaitForExit line. Ok, I am doing Process. Close in the finally block of my code, so it should be taken care system.diagnostics.process then. Pardon my "not own"ing comment that I made previously. I just came back form lunch and was missing the fact that the process has control of this. Close is the recommended method of closing the standardinput and standardoutput and standarderror streams. By only calling Close on something which implements IDisposable, the developer is potentially making a mistake. If Dispose does some additional cleanup beyond just delegating to Close, then the programmer is setting himself up waitforexit a bug by just calling Close. There may be a case for calling Close, but only if you're not done with the object, as you indicated at the waitforexit of your last reply. But when done with it, call Dispose. But yes, that's what a using statement is "functionally equivalent" to; but I don't agree explicitly calling Dispose in the presence of a "Close" method should be the first choice because of the lack scoping with the Dispose call. For example, the following:. I uncommented the sIn. Close line just now and re-started the service and the Client and everything is working like it did before. I can hit the breakpoint after the WaitForExit and I complete, with the Windows Error Reporting message still as it was before. So, in my case, I NEED to close the input stream to be able to exit the process as expected. Are there any other ideas? How are you using the standard input and the standard output? Waitforexit you using any ReadLine methods? If you don't call Dispose on an object which implements directly or indirectly IDisposable, then you're just asking for a bug. I don't want to argue on this endlessly though. You can continue to do it the way you do, and I'll stick with mine. As long as we don't have to maintain each others' code, fine. And by the way, a "using" block doesn't protect you either. Nothing stops you from declaring the variable outside the block if I recall correctlyso it can still be in scope after the block ends. You have to be diligent in writing correct code. If you declare it in the "using" statement, that's one way. It still needs to be Dispose 'd somewhere. Again, this is NOT an Exception that is being thrown, so I am not seeing any exception details. I do not go directly to the catch block in my code, I resume DIRECTLY after the WaitForExit call. The window I am receiving is the same one you get when ANY Microsoft product unexpectedly closes and MS wants information about the Crash. So again, there is NO exception details. However in one of the System Logs, I am receiving a mesage translated from Japanese. For more information, http: I am redirecting the Standard input to pass in the different commands in because I was having trouble getting them to work how I wanted form the StartInfo. I am redirecting the Output and Error streams to check what they have in them after the process has exited. This will allow me to check for anything that I would like in either stream once we have finished. I also do not allow either of the output or error redirection threads to join until after the process has passed the WaitForExit call. It's not a "bug" to not call Dispose. Your resources won't get freed right away, but the GC will release them if it needs the memory assuming the Dispose pattern is properly implemented and a finalizer exists. If the class you're using implements a "Close" method that doesn't do all the same things as "Dispose", Close should either be documented as such or there's a bug in system.diagnostics.process class. I've never encountered a framework class that implements IDisposable system.diagnostics.process a Close method that introduced a "leak" when Close was called without calling Dispose. In fact this is detailed in the. NET Framework General Reference: For example, a file encapsulation might want to use the method name Close. In this case, implement Dispose privately and create a public Close method that calls Dispose. The following code example illustrates this pattern. You can replace Close with a method name appropriate to your domain. As well as "For certain classes of objects, such as files or database connection objects, a Close method better represents the logical operation that should be performed when the object's consumer is finished with the object. I assumed your application was generating the message in which case you should always get an exception and a stack waitforexit ; it wasn't clear that you resume after the call to WaitForExit. It sounds to me like the application you're running is terminating abnormally. Are you running devenv. I'm not sure what you can do in your application to stop another application from terminating abnormally. Hence the reason why I kept stating that it is was not an exception and that my code still funcitoned the rest of the way to completion, as expected. The survey will appear here when you've completed your visit, so please do not close this window. Microsoft is conducting an online survey to understand your opinion of the Msdn Web site. If you choose to participate, the online survey will be presented to you when you leave the Msdn Web site. Gallery MSDN Library Forums Get started for free. Remove From My Forums. Sign in to vote. Thursday, October 25, 8: Monday, October 29, 7: This only occurs when you are redirecting input and output? Thursday, October 25, 9: No, I can redirect input and output without a problem. The error that I am receiving is the general windows error reporting and unfortunately, it is in Japanese so I do not know what the exact error is, but it is the general error. I wil try it tomorrow remoting on a non-Japanese machine at work and I will post my findings regardless. Friday, October 26, 2: If yes then you have to type exit also. Friday, October 26, 4: Try disabling the output redirection and see if the process exits. Give it a try, it might work. Friday, October 26, Thank you for your help, but I am getting really frustrated with this problem. System.diagnostics.process, October 26, 3: Without knowing the detail of the message we're just guessing at the problem Close ; Why are you doing this? WaitForExit ; Is this a typo? Before you were talking about a variable named "proc", not "Proc". So is this simply a null reference because you're trying to invoke a method on a different reference than "proc"? Do you have the stack trace from that error message? The Proc was a type, it should have been proc. Friday, October 26, 5: I would be surpised if the Dispose method didn't call Close, at least as part of its operation. I would favor using the fact that since Process implements IDisposable indirectly thru extending Component which implements itone should invoke Dispose and let that to the proper cleanup. I wouldn't recommend invoking Process. Close instead of, nor in addition to, Process. Friday, October 26, 6: So, I set a breakpoint after the proc. WaitForExit call and I have not yet hit this breakpoint So that seems like it is quite a problem Friday, October 26, 7: I can recomment the sIn. Close line if you would like to check something. Peter, my point is: System.diagnostics.process am waitforexit stumped. Friday, October 26, 8: The only thing I can think about is creating an application that is running on the server and monitor windows comming form the processes that you are controling remotely and then find the correct buttons and press them programaticaly pusing a message to the message pump of waitforexit dialog window. Waitforexit alos happens with excel, word and other applications that can be used with autimation MSFT did not design these applications to be run without user interaction so once in a while you will get windows on errors. Have you considered using MSBuid that is more appropiate for batch builds, also it seems that in TFS build servers will be easy to build. Saturday, October 27, Would you like to participate? Dev Centers Windows Office More Related Sites Visual Studio Visual Studio Integrate VSIP Program Microsoft. system.diagnostics.process waitforexit c#

5 thoughts on “System.diagnostics.process waitforexit c#”

  1. GruNT says:

    Apple is not responsible for the operation of this device or its compliance with safety and regulatory standards.

  2. accumulator says:

    Whoever wants to interpret these things ought to bring to them not an extensive vocabulary and a facility of expression but a power and an intellect new to human souls.

  3. all88 says:

    The pointer cannot be declared with the INTENT or PARAMETER attributes.

  4. admonz says:

    Davidson - US: A Narrative History - 2e, Test Bank, ISBN 0073385662.

  5. Alexhof says:

    In Cantonese medicine, ordinary illnesses were imbalances of heat, cold, wetness and dryness—the classic four qualities of Hippocratic-Galenic medicine.

Leave a Reply

Your email address will not be published. Required fields are marked *

inserted by FC2 system