private void deploy_Click(object sender, EventArgs e) { addMessage(">>Reading deployment JSON"); System.IO.StreamReader file = new System.IO.StreamReader("json.txt"); String json = file.ReadLine(); file.Close(); addMessage(">>Reading finished"); foreach (STCSession s in UserList) { tryConnect(s); byte[] msgToSend = Encoding.UTF8.GetBytes("d" + json); addMessage(">>Writing deployment message"); IAsyncResult res = Stream.BeginWrite(msgToSend, 0, msgToSend.Length, new AsyncCallback(writeComplete), null); Stream.EndWrite(res); addMessage(">>Deployment message written"); } }