Process.Start() is blocking

J

jrm

..Net v1.1

I am trying to launch a MS Word merge document. It is linked to an Access mdb that has a parameterized query that pops up an input dialog when you open it. None of this should matter of course, but I think maybe it is causing the problem..?

I am doing this:
System.Diagnostics.Process merge_doc = new System.Diagnostics.Process();
merge_doc.StartInfo.FileName = "c:\adoc.doc";
merge_doc.Start();

The start call is blocking until I close the popup input form... ?! Even stranger is that a message loop is still running somewhere because my main application continues to run. The menu handler in which I start the process does in fact block though. Eventually control returns once I close that Access popup, like I said. I thought Start() was not supposed to block? Workarounds?

thx
 
R

rossum

.Net v1.1

I am trying to launch a MS Word merge document. It is linked
to an Access mdb that has a parameterized query that pops up
an input dialog when you open it. None of this should matter of
course, but I think maybe it is causing the problem..?

I am doing this:
System.Diagnostics.Process merge_doc = new System.Diagnostics.Process();
merge_doc.StartInfo.FileName = "c:\adoc.doc";
merge_doc.Start();
You have "\a" in your filename string, which is the ASCII BEL
character - it sounds a beep. You need to use one of the standard
alternatives:

@"c:\adoc.doc"
"c:/adoc.doc" - Windows understands unix-style paths
"c:\\adoc.doc"

I suspect that it is blocking because it is looking for a file called:
"c:%doc.doc", where % is the BEL character. It is not finding the
file and hanging. You should also look at how you are checking for
errors if not finding the target file causes a hang; maybe check that
the file exists before trying to open it.

rossum
 
J

jrm

No, im sorry. That was a typo. I didnt copy the code verbatim... Yes do I have double slashes \\ in the pathname string.

I just tried to pinvoke ShellExecute() and it has the exact same behavior. Not only does it block, but it runs a message loop while doing so. Totally weirdo.

I found a workaround though. I can put the 'start adoc.doc' command in a .bat file, or pinvoke CreateProcess something like CreateProcess(.."WINWORD.EXE", "open adoc.doc"...). These do not block.
 

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