Exemple #1
0
        public Transmitter(BlockingCollection <IEmail> requestQueue, ILoggable logger)
        {
            try
            {
                _logger          = logger;
                _requestQueue    = requestQueue;
                _exitThreadEvent = new CancellationTokenSource();

                new Thread(TransmitterThread).Start(new TransmitterThreadData {
                    Logger = logger, Queue = requestQueue, ExitCancelationToken = _exitThreadEvent.Token
                });
            }
            catch (Exception ex)
            {
                logger.LogException(ex);
            }
        }
Exemple #2
0
        public bool Transmit(IEmail email)
        {
            try
            {
                Parallel.ForEach(
                    email.RecepiantSettings.RecepiantList,
                    recepiant => { recepiant.TransmitState = TransmitState.Pending; });

                _requestQueue.Add(email);
                return(true);
            }
            catch (Exception exception)
            {
                _logger.LogException(exception);
            }

            return(false);
        }