Hi, thank you for more clarified process you have.
"1. from time to time I get the command i send, back as a replay to the OnDataReceived"
This is actually correct behaviour. As I wrote earlier, the server sends back the commands as a confirmation that it receive it correctly. And also, this response is usually shown to the user who typed the command. These are also received data and so they appear in DataReceived
event.
"2. the Scripting.Process always wait the full time..."
This is really strange. I wrote a test to see how it behaves and the Scripting.Process(60 * 1000)
returned immediately after a packet is received. But, as I wrote earlier, the packet does not necessarily contains the whole response. What duration do you get from this sample code? (Please, try it without handling DataReceived event completly.)
// send command
scripting.Send("sample command\n");
// process response
int start = Environment.TickCount;
scripting.Process(60*1000); // one minute
// print Process duration
int duration = Environment.TickCount - start;
Console.WriteLine(duration);
Additionally, the DataReceived event is raised within the Process method, so its processing time is added to processing time of Scripting.Process() itself.
"Will ReadUntil pass control when data finished to arrive?"
This is not so easy to answer. It will return control immediately when you read until "some string" and "some string" appears in received data. Scritping.ReadUntil(...)
receives more than one packet (internally it calls Process() in a loop, so DataReceived
event is also raised) until it receives the condition provided in its parameter. But, there are some conditions that are used for tracking time. This is not your case, so we may assume that: Yes, it will return immediately.