visual studio – C # Client-Server sends data as desired

I have a problem with my client and server applications, I have a server application that sends data to a client and the latter displays them in one form, the server that sends is the following:

public bool Connect (string iprasp)
{
Console.WriteLine ("Connecting the screen ...");
connection = true;
series chain;
// Always call UpdateDeviceList () before using AndroidController on devices for the most up-to-date list
//android.UpdateDeviceList ();
// if (android.ConnectedDevices.Count> 0)
// {
// try
/ * {
serial = android.ConnectedDevices[0];
device = android.GetConnectedDevice (series);
}
catch (Exception e)
{
connection = false;
Console.WriteLine (e.StackTrace);
Statistics.registerError (this.serial, Statistics.Error_Item.CODIGO.SOFTWARE, e.StackTrace);
connected = false;
connected (connected);
returns false;
}
if (android.HasConnectedDevices)
{* /
AdbCommand adbCmd = Adb.FormAdbCommand ("transfer", "tcp:" + port1 + "tcp:" + port2);
int result = Adb.ExecuteAdbCommandReturnExitCode (adbCmd);
// if (result == 0)
// {
try
{
if (socket! = null)
{
socket.Close ();
flow.Close ();
//input.Close ();
//output.Close ();
}
// string ippc = "192.168.1.180";
// socket = new TcpClient (ippc, port1);
socket = new TcpClient (iprasp, port1);
if (socket.Connected)
{
stream = socket.GetStream ();
//stream.ReadTimeout = 1000;
input = new StreamReader (stream);
output = new StreamWriter (stream);
output.AutoFlush = true;
connected = true;
connected (connected);
//output.WriteLine("OK ");
MessageBox.Show ("Display connected");
}
otherwise Console.WriteLine ("Tablet connection socket () not connected");
}
catch (SocketException e)
{
connection = false;
Console.WriteLine ("TabletClient SocketException");
//Statistics.registerError (serial, Statistics.Error_Item.CODIGO.SOFTWARE, e.StackTrace);
Console.WriteLine (e.StackTrace);
connected = false;
connected (connected);
// Disconnect ();
}
catch (FormatException e)
{
connection = false;
Console.WriteLine ("TabletClient FormatException");
//Statistics.registerError (serial, Statistics.Error_Item.CODIGO.SOFTWARE, e.StackTrace);
Console.WriteLine (e.StackTrace);
connected = false;
connected (connected);
// Disconnect ();
}
catch (Exception e)
{
connection = false;
Console.WriteLine (e.StackTrace);
}
//}
//}
//}
connection = false;
back connected;
}

This is the connection method with the client, and to send data, it does it with the following method:

public void sendText (string line1, string line2)
{
//Console.WriteLine ("sendText ()");
if (socket! = null && socket.Connected)
{
try
{
//output.Write(linea1);
output.Flush ();
Result of the string = line2 + " n";
String result2 = line1 + " n";
output.Flush ();
//output.Write(result2);
output.Flush ();
output.Write (result);
output.Flush ();
}
catch (IOException e)
{
Console.WriteLine ("TabletClient IOException" + e.Message);
Statistics.registerError (serial, Statistics.Error_Item.CODIGO.SOFTWARE, e.StackTrace);
//Console.WriteLine(e.StackTrace);
socket.Close ();
input.Close ();
output.Close ();
connected = false;
connected (connected);
}
catch (ObjectDisposedException e)
{
if (socket! = null)
stream = socket.GetStream ();
if (stream! = null)
input = new StreamReader (stream);
if (stream! = null)
output = new StreamWriter (stream);
}
catch (Exception e)
{
Console.WriteLine (e.StackTrace);
}
}
}

And the data is sent in the following way:

display.enviaText ("Enter", ((float) amountShoptInt / 100) .ToString ("0,00"));
Thread.Sleep (4000);

String totalinput2 = Convert.ToString (totalIntroducedFloat);
display.enviaText ("In", ((float) totalIntroductedInt / 100) .ToString ("0,00"));
Thread.Sleep (4000);
String returned = (((float) amountShortInt / 100) - totalIntroducedFloat) .ToString ("0.00");
display.enviarTexto ("Returned", returned);

The thing is this: in my client application that is asynchronous, when receiving data by the stream, it stores them in a directory, when the latter arrives at the account 3, it launches the method that displays them in the directory. ;screen:

blank static public ReadCallback (IAsyncResult ar)
{
String content = String.Empty;

// Get the state object and the manager socket
// from the asynchronous state object.
StateObject state = (StateObject) ar.AsyncState;
Socket Manager = state.workSocket;


// Read the data from the client socket.
int bytesRead = handler.EndReceive (ar);

if (bytesRead> 0)
{
// There may be more data, so store the data received until now
state.sb.Append (Encoding.ASCII.GetString (
state.buffer, 0, bytesRead));
//Console.WriteLine(bytesRead);
// Check the end-of-file tag. If it's not there, read on
// more data.
content = state.sb.ToString ();

//Console.WriteLine(content);
ListaV.Add (content);
/ * string value = content;
Console.WriteLine (value);
Form1 obj = new Form1 ();

//obj.Show ();
obj.mostrarvaloretroduce (value);
obj.Show ();
obj.Close ();
* /
for (int i = 0; i < ListaV.Count; i++) {
                Console.WriteLine("Dentro de la lista "+ListaV[i]);
            }
            string s = (string)ListaV[ListaV.Count - 1];
            //Console.WriteLine(s);

            if (ListaV.Count >= 3) {
Form1 obj = new Form1 ();
state.sb.Clear ();

obj.Show ();
obj.llamarArray (ListV);
obj.Show ();
obj.Close ();
ListV.Clear ();
}


public void callArray (ArrayList list) {

string lastvalue = list (string)[lista.Count-1];
//Console.WriteLine("ultimovalue"+lastvalue);
string[] values ​​= lastvalue.Split (" n" .ToCharArray (), StringSplitOptions.RemoveEmptyEntries);

Console.WriteLine ("1" + values[valores.Count() - 1])
change = values[valores.Count() - 1];

label2.Text = change;
//labelofvolume.Text = change;
label2.Invalidate ();
label2.Update ();


label2.Invalidate ();
label2.Update ();

//MessageBox.Show(label2.Text);
this.Refresh ();
this.Invalidate ();
Console.WriteLine ("2" + values[valores.Count() - 2])
introduced = values[valores.Count() - 2];
label1.Text = entered;
// labelentregado.Text = entry;
//MessageBox.Show(label1.Text);
this.Refresh ();
this.Invalidate ();
Console.WriteLine ("3" + values[valores.Count() - 3])
turn off = values[valores.Count() - 3];
label3.Text = switch off;
// labeltotal.Text = extinguish;
//MessageBox.Show(label3.Text);
this.Refresh ();
this.Invalidate ();
Application.DoEvents ();
Thread.Sleep (10000);

// foreach (string element in values) {Console.WriteLine ("Values ​​to place" + element); };
}

My doubt is related to the communication method of the client server, it sometimes sends me all the data at the same time, the 3 data, and sometimes I send them one by one or two and I decompensated the arraylist and all false as a result, I wanted to know what is this behavior and if there is a possible solution.

Greetings.