myprocess.WaitForExit()   Problem

garyinmiami2003
garyinmiami2003 used Ask the Experts™
on
I am getting a "Server Busy " error during this step.  "The action can't be completed because the other program is busy".  I'm sure the message is coming from this statement in title line not in the Catch

 
With myprocess.StartInfo
             .FileName = strPath & "ZYCOBMNT.exe" & " "
            .Arguments = strParms
            .CreateNoWindow = True
            .ErrorDialog = False
            .UseShellExecute = False
            .RedirectStandardOutput = True
            .RedirectStandardError = True
            .RedirectStandardInput = True
            .WindowStyle = ProcessWindowStyle.Hidden
            .CreateNoWindow = True
        End With
        Try
            myprocess.Start()
        Catch ex As Exception
 
            MessageBox.Show(ex.Message)
        End Try
 
          '// Wait for Exited event, but not more than 10 seconds.
 
 
            Try
            myprocess.WaitForExit()
        Catch ex As Exception
 
        End Try

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You have .CreateNoWindow = True in there twice.
Also remove the .WindowStyle = ProcessWindowStyle.Hidden  and give it a shot.

If that doesn't help, run the command prompt and run the .exe from the cmd prompt using the same parameters.

That should narrow down the issue.

Author

Commented:
shahprabal:

Did all that and got the same error.  The Calling app has no screen and exists just to call a EXE.  The calling program has to wait for the EXE to close before it returns  "True" back to the main app.

Shouldn't I have CreatNoWindow (only once) and ProcessWindowStyle.Hidden?
Didn't seem to matter when I tested though.  Still have problem
I understand that you don't want the calling app to show... Lets get the process to trigger successfully and then we can get it to hide.

So you tried running the app from the command line? Did you get a similar error?

What happens why you only set the filename and the arguments property and try to run it?

http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.useshellexecute.aspx

Also, you might want to consider triggering this process through a windows service.
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

Author

Commented:
shahprabal

I can't run the exe from the command line.  The command line argument is too long and cumbersome.  It is actually an xml file ramped in quotes to make it look like a string.  so forget that.  I have tried all suggestions I know of but that and need answer bad.

Restate the problem: When I use Process.WaitForExit().  The called program exits and I immediately get a "server busy" message.  I'm sure that it is in the WaitForExit() function that this happens.

When I get the "Server Busy", I can select 'Retry" or "Switch To".  One retry closes and the process finishes as it should.  The Server busy Dialog Box is a big nuiscance and I ahve to get rid of it.  Can any body help?
   
The command line argument is too long and cumbersome.  It is actually an xml file ramped in quotes to make it look like a string

>> So set a breakpoint, copy the value of the strParms, open cmd, type the command and paste the argument...


 I'm sure that it is in the WaitForExit() function that this happens.

>> By running it in the command prompt you are narrowing down the issue. It is either the program's fault (if it acts the same way when you call it from the cmd prompt), or the arguments. You can also create a batch file if that's easier.

Author

Commented:
shahprabal

Just can't do that, sorry.  Care to take a look about how to supress the box, handle, something else?

   
Most Valuable Expert 2012
Top Expert 2014

Commented:

Author

Commented:
CodeCruiser:
It is in vb.net not c#.  It is a Windows app not a web app.  Actually it may be important to finding a solution to know that it is actually a com class and it loads a server based assembly  
Most Valuable Expert 2012
Top Expert 2014

Commented:
>It is in vb.net not c#
That is irrelevant as the code can be converted between the two.

> It is a Windows app not a web app.
If you try once more, believe me you would discover that the example application in that article is also windows application. It just happens to be using a webbrowser control to demonstrate the poping up of unexpected windows.

Author

Commented:
CodeCruiser

If implementing this will solve my problem how about a code sample fittin in with the code I provided.
I will close the question and award the points and be very grateful

Author

Commented:
The solution Never really got at the problem.  I beleve the content of the question caused this rather than the expert's solution.  It is possible a 'B' IS LOWER THAN WHAT'S DESERVED. Moderator:  Please change it if you think differently.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial