In a button click event I need to send 5 different commands recieve each output one by one.

My code for only one command is (its works):

TcpClient socketForServer;
            socketForServer = new TcpClient("", 2211);
            NetworkStream networkStream = socketForServer.GetStream();
            System.IO.StreamReader streamReader = new System.IO.StreamReader(networkStream);
            System.IO.StreamWriter streamWriter = new System.IO.StreamWriter(networkStream);

            string command = command.Text;
            streamWriter.WriteLine(command + "");

            //wait for and retrieve response

           string outputString;
           socketForServer.ReceiveTimeout = 5000;
           outputString = streamReader.ReadToEnd();
           textxml.Text = outputString;

For example:

send command1 socket recieve output1 in textbox1, then take value from xml
send command2 recieve ouput2 in textbox2, then take value from xml

My difficult is to create this kind of "cycle" of command, result in only one button click event. I need cycle because the other software from send the command only receive one command then gives the output, one by one.

Thanks in advance

This question has already been answered. Start a new discussion instead.