private void MessageCallBack(IAsyncResult Result) { Tuple <byte[], int, int> RData = (Tuple <byte[], int, int>)Result.AsyncState; byte[] SendData = RData.Item1; byte[] SendBytesR = new byte[SizeForOne + 4]; int SendCount = RData.Item2; int TotalLength = RData.Item3; //ChatBox.Items.Add(SendCount.ToString() + ":" + TotalLength.ToString()); SendCount++; if (SendCount * (SizeForOne) > TotalLength) { return; } else if ((SendCount + 1) * (SizeForOne) >= TotalLength) { //ImageClient.BeginSendTo(SendData, SizeForOne * SendCount, TotalLength - (SizeForOne * SendCount), SocketFlags.None, IPBindPoint_ForImage, new AsyncCallback(MessageCallBack), Tuple.Create(SendData, SendCount, TotalLength)); Client.Send(new byte[4]); ImageClient.SendTo(SendData, (SendData.Length / SizeForOne) * SizeForOne, SendData.Length - (SendData.Length / SizeForOne) * SizeForOne, SocketFlags.None, IPBindPoint_ForImage); } else { Array.Copy(BitConverter.GetBytes(SendCount), 0, SendBytesR, 0, 4); Array.Copy(SendData, SendCount * SizeForOne, SendBytesR, 4, SizeForOne); ImageClient.BeginSendTo(SendBytesR, 0, SizeForOne + 4, SocketFlags.None, IPBindPoint_ForImage, new AsyncCallback(MessageCallBack), Tuple.Create(SendData, SendCount, TotalLength)); } }