Click here to Skip to main content
15,887,596 members

Comments by Johannes Grunedal (Top 7 by date)

Johannes Grunedal 20-Apr-15 5:01am View    
Great! Hmm, I was wondering. As I said, I suspect the problem could be in my external application but shouldn't be able to read and write to a standard cmd window? I mean if I just pass cmd.exe as command? However, that doesn't work either. I can only read once AFTER the cmd window is closed (by me). Maybe that could be a clue to what is going on...

Your "5" is coming sooooon ;)
Johannes Grunedal 20-Apr-15 4:24am View    
Hi again!
I give you 4 for the quick answer and for the complete class. It doesn't do exactly as I want but that may be an internal problem of my application.
Johannes Grunedal 18-Apr-15 3:39am View    
Ah, that could maybe explain it. I notice that a console window pops up and when I close, I can read the first result. I think that is why the SendCommand doesn't work, the 'process' or console is closed. I'm trying to figure out why and how to prevent that from happening.

Thanks for all the help.
Johannes Grunedal 17-Apr-15 17:09pm View    
Wow!
I'm impressed with all the effort you have put down into this.
I must admit your'e out of my league and I have some catching up do to ;)

I was forced to do some small adjustments to make your code compile and maybe I messed things up (I'm sure the errors are on my side):
I replaced the queue 'output' with 'Output', moved up the _process.Start() before the '_inputStreamWriter = _process.StandardInput;' line.

The process still 'seem' to get closed because I read valid data only the first time and no matter how many times I run the SendCommand function it doesn't seem to 'bite'. I tried to debug but I haven't found where exactly the problem lies. When I debug I get an exception here:
if (args.Data == null)
{
//the pipe has closed. i.e. the process has ended
_waitHandles[1].Set();
}

And to get rid of that I needed to add this:
_waitHandles[1] = new ManualResetEvent(false);

Don't get me wrong, I really appreciate the help from you, I just try to explain my point of view. I'm sure the problem is on my side somewhere.
I will dig deeper tomorrow.

Have a nice weekend.
Johannes Grunedal 17-Apr-15 9:27am View    
Hi again!
My commands looks like this. RunExternalApplication.exe, listUnit, ReadCommand, WriteCommand etc.
After each sent command the application return with success info and actual data (that's why I need to keep the 'line' open).

No, I can't (or rather not) choose to log in every time since it may take up to one minute for each login procedure to complete (stupid system which communicates with aonther hardware).
So if possible, a one time login followed by severel commands is of great importance.

However, thanks for clarifying how the redirecting works, much appreciated.

Regards
Cypres