Assert() 개인적인 메소드

private Assert ( bool Condition, string Message, string DetailMessage ) : void
Condition bool
Message string
DetailMessage string
리턴 void
예제 #1
0
        /// <summary>
        /// Sends data via the socket asynchronously
        /// </summary>
        /// <param name="Message">Data to transmit</param>
        public void Send(ResponseData Message)
        {
            IBuffer sendBuffer = null;

            //TODO: ENHANCEMENT: Log consecutive bad request response types and use that information to disconnect socket after 3
            try
            {
                lock (syncSocket)
                {
                    if (sentMsgs.Count > 1)
                    {
                        sentMsgs.Dequeue();
                    }
                    sentMsgs.Enqueue(Message);

                    //Log error if .Data is null -- this will help raise a flag if the message is being resent after .ClearData was called
                    Diags.Assert(Message.Data != null, "ASSERTION FAILED: Message Data is null", new System.Diagnostics.StackTrace().ToString());

                    sendBuffer = bufferPool.GetBuffer(Message.Data.LongLength);
                    sendBuffer.CopyFrom(Message.Data);
                    socket.BeginSend(sendBuffer.GetSegments(), SocketFlags.None, CompleteSend, sendBuffer);

                    Message.ClearData(); //free some memory
                }
            }
            catch (Exception ex)
            {
                Diags.LogSocketException(ex);
                if (sendBuffer != null)
                {
                    sendBuffer.Dispose();
                    sendBuffer = null;
                }
            }
        }