private async Task ProcessBatches(List <RoutedItem> association, DicomClient dicomClient, int taskID, string taskInfo, Stopwatch stopWatch)
        {
            //queue up the requests for this association
            foreach (var ri in association)
            {
                switch (ri.requestType)
                {
                case null:
                case "cStore":
                    CStore(ri, taskID, dicomClient);
                    break;

                case "cFind":
                    CFind(ri, taskID, dicomClient);
                    break;

                case "cMove":
                    CMove(ri, taskID, dicomClient);
                    break;
                }
            }

            if (dicomClient.IsSendRequired && dicomClient.CanSend)
            {
                _logger.Log(LogLevel.Debug, $"{taskInfo} calling SendAsync...");

                DicomSendRequestService dicomSendRequest = new DicomSendRequestService(dicomClient, Connection, _logger);

                try
                {
                    await dicomSendRequest.SendRequest(taskInfo, stopWatch);

                    #region old code
                    //await Task.Run(async () =>
                    //{
                    //    await dicomClient.SendAsync(Connection.remoteHostname, Connection.remotePort, Connection.useTLS, Connection.localAETitle, Connection.remoteAETitle);

                    //    _logger.Log(LogLevel.Debug, $"{taskInfo} SendAsync complete elapsed: {stopWatch.Elapsed}");

                    //    await Task.Delay(Connection.msToWaitAfterSendBeforeRelease).ConfigureAwait(false);

                    //    _logger.Log(LogLevel.Debug, $"{taskInfo} Releasing: {stopWatch.Elapsed}");

                    //    await dicomClient.ReleaseAsync();
                    //});
                    #endregion
                }
                catch (TaskCanceledException)
                {
                    _logger.Log(LogLevel.Information, $"Task was canceled.");
                }
                catch (AggregateException e)
                {
                    _logger.Log(LogLevel.Warning, $"{taskInfo} SendAsync: {e.Message} {e.StackTrace}");

                    foreach (Exception exp in e.InnerExceptions)
                    {
                        if (exp != null && exp.Message != null)
                        {
                            _logger.Log(LogLevel.Warning, $"{taskInfo} Inner Exception: {exp.Message} {exp.StackTrace}");
                        }
                    }
                }
                catch (DicomAssociationRejectedException e)
                {
                    foreach (var context in dicomClient.AdditionalPresentationContexts)
                    {
                        if (!(context.Result == DicomPresentationContextResult.Accept))
                        {
                            _logger.Log(LogLevel.Warning, "Not Accepted: " + context.GetResultDescription());
                        }
                    }

                    _logger.Log(LogLevel.Warning, $"{taskInfo} SendAsync: {e.Message} {e.StackTrace}");
                }
                catch (Exception e)
                {
                    _logger.LogFullException(e, $"{taskInfo} SendAsync: ");
                }
            }
        }
        public async Task CEcho(DICOMConnection Connection, int taskID)
        {
            Throw.IfNull(Connection);

            var taskInfo  = $"task: {taskID} connection: {Connection.name}";
            var stopWatch = new Stopwatch();

            stopWatch.Start();

            //just c-echo the host to say hello

            dicomClient.AddRequest(new DicomCEchoRequest());

            DicomSendRequestService dicomSendRequestService = new DicomSendRequestService(dicomClient, Connection, _logger);

            try
            {
                await dicomSendRequestService.SendRequest(taskInfo, stopWatch);

                #region old code
                //await Task.Run(async () =>
                //{
                //    await dicomClient.SendAsync(Connection.remoteHostname, Connection.remotePort, Connection.useTLS, Connection.localAETitle, Connection.remoteAETitle);

                //    _logger.Log(LogLevel.Debug, $"{taskInfo} SendAsync complete elapsed: {stopWatch.Elapsed}");

                //    await Task.Delay(Connection.msToWaitAfterSendBeforeRelease).ConfigureAwait(false);

                //    _logger.Log(LogLevel.Debug, $"{taskInfo} Releasing: {stopWatch.Elapsed}");

                //    await dicomClient.ReleaseAsync();
                //});
                #endregion
            }
            catch (TaskCanceledException)
            {
                _logger.Log(LogLevel.Information, $"Task was canceled.");
            }
            catch (AggregateException e)
            {
                _logger.Log(LogLevel.Warning, $"{taskInfo} SendAsync: {e.Message} {e.StackTrace}");

                foreach (Exception exp in e.InnerExceptions)
                {
                    if (exp != null && exp.Message != null)
                    {
                        _logger.Log(LogLevel.Warning, $"{taskInfo} Inner Exception: {exp.Message} {exp.StackTrace}");
                    }
                }
            }
            catch (DicomAssociationRejectedException e)
            {
                foreach (var context in dicomClient.AdditionalPresentationContexts)
                {
                    if (!(context.Result == DicomPresentationContextResult.Accept))
                    {
                        _logger.Log(LogLevel.Warning, "Not Accepted: " + context.GetResultDescription());
                    }
                }

                _logger.Log(LogLevel.Warning, $"{taskInfo} SendAsync: {e.Message} {e.StackTrace}");
            }
            catch (Exception e)
            {
                _logger.LogFullException(e, $"{taskInfo} SendAsync:");
            }
        }