コード例 #1
0
        private void SendMessageToNeighbor(IPeerNeighbor neighbor, Message message, PeerMessageHelpers.CleanupCallback cleanupCallback)
        {
            bool flag = false;

            try
            {
                neighbor.Send(message);
            }
            catch (Exception exception)
            {
                if (Fx.IsFatal(exception))
                {
                    flag = true;
                    throw;
                }
                if ((!(exception is CommunicationException) && !(exception is QuotaExceededException)) && (!(exception is ObjectDisposedException) && !(exception is TimeoutException)))
                {
                    throw;
                }
                DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Information);
                if (cleanupCallback != null)
                {
                    cleanupCallback(neighbor, PeerCloseReason.InternalFailure, exception);
                }
            }
            finally
            {
                if (!flag)
                {
                    message.Close();
                }
            }
        }
コード例 #2
0
ファイル: PeerConnector.cs プロジェクト: dox0/DotNet471RS3
        //this method takes care of closing the message.
        void SendMessageToNeighbor(IPeerNeighbor neighbor, Message message, PeerMessageHelpers.CleanupCallback cleanupCallback)
        {
            bool fatal = false;

            try
            {
                neighbor.Send(message);
            }
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    fatal = true;
                    throw;
                }
                if (e is CommunicationException ||
                    e is QuotaExceededException ||
                    e is ObjectDisposedException ||
                    e is TimeoutException)
                {
                    DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);
                    // Message failed to transmit due to quota exceeding or channel failure
                    if (cleanupCallback != null)
                    {
                        cleanupCallback(neighbor, PeerCloseReason.InternalFailure, e);
                    }
                }
                else
                {
                    throw;
                }
            }
            finally
            {
                if (!fatal)
                {
                    message.Close();
                }
            }
        }