public override void Dispose() { if (Interlocked.Exchange(ref DisposedValue, 1) == 1) { return; } if (IsConsumer) { _providerService.FinishSessionsAsync(this).ContinueWith(t => { if (t.IsFaulted && Logger.IsError) { Logger.Error("There was an error within NDM subprotocol.", t.Exception); } }); _receiptsRequests?.CompleteAdding(); _receiptsRequests?.Dispose(); } if (!IsProvider) { return; } ConsumerService.FinishSessionsAsync(this).ContinueWith(t => { if (t.IsFaulted && Logger.IsError) { Logger.Error("There was an error within NDM subprotocol.", t.Exception); } }); DepositApprovalsRequests?.CompleteAdding(); DepositApprovalsRequests?.Dispose(); }