コード例 #1
0
 public void SendResponse(int channelId, int requestId)
 {
     if (IsEnabled())
     {
         WriteEvent(SendResponseId, channelId, requestId);
     }
     else if (Utils.Logger.IsEnabled(LogLevel.Trace))
     {
         Utils.LogTrace(SendResponseEventId, SendResponseMessage, channelId, requestId);
     }
 }
コード例 #2
0
 public void ServiceCallBadStop(string serviceName, int requestHandle, int statusCode, int pendingRequestCount)
 {
     if (IsEnabled())
     {
         WriteEvent(ServiceCallBadStopId, serviceName, requestHandle, statusCode, pendingRequestCount);
     }
     else if (Utils.Logger.IsEnabled(LogLevel.Trace))
     {
         Utils.LogTrace(ServiceCallBadStopEventId, ServiceCallBadStopMessage, serviceName, requestHandle, statusCode, pendingRequestCount);
     }
 }
コード例 #3
0
 public void Trace(int mask, string format, params object[] args)
 {
     if (IsEnabled())
     {
         Trace(Utils.Format(format, args));
     }
     else if (Utils.Logger.IsEnabled(LogLevel.Trace))
     {
         Utils.LogTrace(mask, format, args);
     }
 }
コード例 #4
0
 /// <summary>
 /// Called when the operation times out.
 /// </summary>
 private void OnTimeout(object state)
 {
     try
     {
         Exception = new TimeoutException();
         m_cts?.Cancel();
         OperationCompleted();
     }
     catch (Exception e)
     {
         Utils.LogTrace(e, "Unexpected error handling timeout for ChannelAsyncResult operation.");
     }
 }
コード例 #5
0
 /// <summary>
 /// Called to dispose the timer.
 /// </summary>
 private void DisposeTimer()
 {
     lock (Lock)
     {
         try
         {
             m_timer?.Dispose();
         }
         catch (Exception e)
         {
             // ignore
             Utils.LogTrace(e, "Unexpected error handling dispose of timer for AsyncResult operation.");
         }
         finally
         {
             m_timer = null;
         }
     }
 }
コード例 #6
0
        /// <summary>
        /// Disposes the wait handle.
        /// </summary>
        /// <param name="set"></param>
        private void DisposeWaitHandle(bool set)
        {
            var waitHandle = Interlocked.Exchange(ref m_waitHandle, null);

            if (waitHandle != null)
            {
                try
                {
                    if (set)
                    {
                        waitHandle.Set();
                    }
                    waitHandle.Dispose();
                }
                catch (Exception e)
                {
                    // ignore
                    Utils.LogTrace(e, "Unexpected error handling dispose of wait handle for AsyncResult operation.");
                }
            }
        }
コード例 #7
0
        /// <summary>
        /// Called to invoke the callback after the asynchronous operation completes.
        /// </summary>
        public void OperationCompleted()
        {
            lock (Lock)
            {
                IsCompleted = true;

                // signal an waiting threads.
                try
                {
                    m_waitHandle?.Set();
                }
                catch (ObjectDisposedException ode)
                {
                    // ignore
                    Utils.LogTrace(ode, "Unexpected error handling OperationCompleted for AsyncResult operation.");
                }
            }

            // invoke callback.
            m_callback?.Invoke(this);
        }