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); } }
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); } }
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); } }
/// <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."); } }
/// <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; } } }
/// <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."); } } }
/// <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); }