Waiting for another process?

  • Thread starter Thread starter Corey Scheich
  • Start date Start date
C

Corey Scheich

I am writing a simple exe that will locate a company file for the user with
minimal input and open it in the appropriate application (Same as Explorer)
Problem is sometimes the user may want to open a few files. I was opening
them in a For....Next loop and it seems that if a file takes longer than a
few seconds to open it is dropping the other files. I presume that I need
to wait for the process that was sent to stop I think what I need to use is


Dim MyProcess as Process

Myprocess = Process.Start(psi)
Myprocess.WaitForInputIdle (INFINITE)

since the program will remain opened so the user can use the file as
desired. Would this be best practice or is there a better way to go about
it.
this.
TIA
Corey Scheich
 
* "Corey Scheich said:
That will work quite well thank you for the direction

Multithreading would be good in addition to your code, but it does in no
way replace your code (your code is OK).
 
I was thinking of adding in in at the end of the sub that I was sending to
another thread and possibly triggering an event to check if everything was
OK. Thank you for the sound advice.

Corey
 
Herfried,
Multithreading would be good in addition to your code, but it does in no
way replace your code (your code is OK).

Why did you think that Corey or I (Cor) had another idea, I wrote that for
the solution as I thought it would be the best practise was probably
multithreading.

Cor
 
* "Cor Ligthert said:
Why did you think that Corey or I (Cor) had another idea, I wrote that for
the solution as I thought it would be the best practise was probably
multithreading.

Well, I only wanted to make sure that the OP didn't understand your
suggestion as a replacement for the code he posted. The OP was asking
if there is any better way to do what the code he posted is doing (IMO).
 
Thank you both for your posts. What Mr. Lighthert suggested was actually a
method I hadn't explored being a newbie, which I don't know if I have
mentioned that on this NG, and I actually thought multithreading would be a
lot more intensive, come to find that it only took about 3 min of reading
and 2 min of code in this situation, 5min to learn a black area per say not
bad. Also Mr. Wagner's post helped me understand that what I had been doing
was in fact a good practice that should not be discounted. Two great
insights from one thread I really appreciate it.

Corey
 
Back
Top