public void Communicate() { try { CommunicationBase comB = new CommunicationBase(); comB.SendMsg("You can send data", mclient); bool run = true; string[] allFile; int count = 0; while (run == true) { string receiveMsg = comB.ReadMessage(mclient); switch (receiveMsg) { case "": run = false; break; default: count++; allFile = receiveMsg.Split('\n'); List <string> bfile = allFile.ToList(); bfile.Remove(bfile.Last()); SendtoAzure(bfile); break; } } this.mclient.Close(); } catch { Trace.WriteLine("Client close the connection"); this.mclient.Close(); } }