private void DataSentInvokeCallback(IAsyncResult ar) { try { DataSent?.EndInvoke(ar); } catch { } }
private void ProcessSend(SocketAsyncEventArgs e) { ClientToken clientToken = (ClientToken)e.UserToken; if (e.SocketError != SocketError.Success) { if (e.SocketError == SocketError.OperationAborted) { return; } //Fire DataSentError event if (DataSendError != null) { if (CallDataSendErrorAsync) { DataSendError.BeginInvoke(this, r => DataSendError.EndInvoke(r), null); } else { DataSendError(this); } } clientToken.ResetSend(); ProcessDisconnect(e); } clientToken.SendBytesRemaining = clientToken.SendBytesRemaining - e.BytesTransferred; if (clientToken.SendBytesRemaining == 0) { //Fire DataSent event if (DataSent != null) { if (CallDataSentAsync) { DataSent.BeginInvoke(this, r => DataSent.EndInvoke(r), null); } else { DataSent(this); } } clientToken.ResetSend(); } else { clientToken.BytesSentAlready += e.BytesTransferred; StartSend(); } }