Threading question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Ok, I'm trying to learn how to use threading, but I've run into a problem.
I'm doing this in VB.Net. I started out making something pretty simple.
Just a sort of wrapper for cmd.exe. I used separate threads to read from
stdin and stderr. It seemed to be working ok. Then I added macros to it.
Here's what's happening. The sub that runs the commands gets called several
times in a row very quickly. It's spawns a new cmd.exe process each time,
and a couple of threads to listen for the output. The problem is that the
commands can take different amounts of time to finish, so the output I get is
all out of order. I need to make sure that the commands run one at a time,
each one waiting until the previous one is done. How exactly can I do that?
 
I meant to say that I'm using separate threads to read from stdout and
stderr. I'm not doing anything with stdin right now. If anyone can help me
with this, it would be much appreciated. Thanks.
 
post some code. i think you chose a difficult example. i think, not to sure
if old age is betraying me, that stdin/out/err are affined. That won't
affect the read order but it may cause some exceptions. if you are trying a
threaded app, how about a simple hello world application

--
Regards,
Alvin Bruney - ASP.NET MVP

[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
Now available @ www.lulu.com/owc, Amazon.com etc
 
Back
Top