Process not ready after WaitForExit

G

GerardCC

Hi,

Simple question: when the following code is executed the process is NOT
ready after the call WaitForExit
_________
Dim shellProc As Process
Dim procStartInfo As New ProcessStartInfo(JobToDo, args)

'Start the process and wait for the results
procStartInfo.UseShellExecute = True
procStartInfo.CreateNoWindow = True
procStartInfo.WindowStyle = ProcessWindowStyle.Hidden
procStartInfo.RedirectStandardOutput = False

shellProc = Process.Start(procStartInfo)
shellProc.WaitForExit()

exitVal = shellProc.ExitCode()
shellProc.Close()
shellProc.Dispose()

____________

WaitForExit should wait indefinitly, but files are still created in a
directory when I retreive the ExitCode (the job started is a file splitter).
Anybody any idea what's wrong?

Thanks in advance,
Gerard
 
P

Peter Duniho

[...]
WaitForExit should wait indefinitly, but files are still created in a
directory when I retreive the ExitCode (the job started is a file
splitter).
Anybody any idea what's wrong?

No, not really. But: are you sure that the process you started is still
running? Is it possible that you're just seeing delayed file system
updates? Alternatively, if you're starting a file splitter process, is it
possible that there are ultimately more processes started, some of which
are actually doing the work you're seeing?

Unfortunately, you're not very specific about what exactly the process
you're starting is doing, so it's not really possible to provide any
detailed advice regarding why it might not be doing what you expect.
However, I would be very surprised if the process you've started directly
has not exited at the point in time that the call to WaitForExit() returns.

Pete
 
G

Gerard

Hi Pete,

Thanks for the answer. The process started is called split (split.exe: it is
a commandline program splitting huge files in parts indicated). I can
imagine that the process is ready and that there is still data to be synced
to disk or that another process will fork/start split. But after a
WaitForExit I do expect that the process ended. The delayed writes means
missing one of the parts split is creating. I guess close and dispose make
things worse (perhaps the last part will be created if these last calls are
not executed).

Actually sometimes the last part is created (5% of the tries), but how to
ensure there are no delayed writes pending?

Thanks,
Gerard

Peter Duniho said:
[...]
WaitForExit should wait indefinitly, but files are still created in a
directory when I retreive the ExitCode (the job started is a file
splitter).
Anybody any idea what's wrong?

No, not really. But: are you sure that the process you started is still
running? Is it possible that you're just seeing delayed file system
updates? Alternatively, if you're starting a file splitter process, is it
possible that there are ultimately more processes started, some of which
are actually doing the work you're seeing?

Unfortunately, you're not very specific about what exactly the process
you're starting is doing, so it's not really possible to provide any
detailed advice regarding why it might not be doing what you expect.
However, I would be very surprised if the process you've started directly
has not exited at the point in time that the call to WaitForExit()
returns.

Pete
 

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

Top