/// <inheritdoc />
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (!disposing)
            {
                return;
            }

            DateTimeOffset endTime;

            try
            {
                InternalReader.Dispose();
            }
            catch (Exception ex)
            {
                endTime = DateTimeOffset.Now;
                OnCommandExecuteEnd(startTime, endTime, ex);

                throw;
            }

            endTime = DateTimeOffset.Now;
            OnCommandExecuteEnd(startTime, endTime);

            CommandExecuteEnd.Deregister();
        }
        private void OnCommandExecuteEnd(DateTimeOffset startTime, DateTimeOffset endTime, Exception exception)
        {
            if (isEnded)
            {
                // Do not fire this event twice
                return;
            }

            isEnded = true;

            var args = new ProfilingEventEndArgs <DbCommand>(null, startTime, endTime, exception);

            CommandExecuteEnd?.Invoke(this, args);
        }