/// <summary> /// Cancels the token that is associated to /// the channel send and receive tasks. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Transport_Closing(object sender, DeferralEventArgs e) { using (e.GetDeferral()) { _channelCancellationTokenSource.Cancel(); } }
/// <summary> /// Cancels the token that is associated to the channel send and receive tasks. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Transport_Closing(object sender, DeferralEventArgs e) { using (e.GetDeferral()) { if (!_consumerCts.IsCancellationRequested) { _consumerCts.Cancel(); } } }
/// <summary> /// Raises the Closing event with /// a deferral to wait the event handlers /// to complete the execution. /// </summary> /// <returns></returns> protected virtual Task OnClosingAsync() { if (!_closingInvoked) { _closingInvoked = true; var e = new DeferralEventArgs(); this.Closing.RaiseEvent(this, e); return(e.WaitForDeferralsAsync()); } return(Task.FromResult <object>(null)); }