Stops a thread by aborting it if configured to do; otherwise it will wait (forever if needed) until the thread dies.
        /// <summary>
        /// Initializes a new instance of the <see cref="MultiWorkerBase" /> class.
        /// </summary>
        /// <param name="workerTerminate">The worker terminate module.</param>
        /// <param name="stopThread">The stop thread.</param>
        protected MultiWorkerBase(WorkerTerminate workerTerminate,
            StopThread stopThread)
            : base(workerTerminate)
        {
            Guard.NotNull(() => workerTerminate, workerTerminate);
            Guard.NotNull(() => StopThread, stopThread);

            StopThread = stopThread;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MultiWorkerBase" /> class.
        /// </summary>
        /// <param name="workerTerminate">The worker terminate module.</param>
        /// <param name="stopThread">The stop thread.</param>
        protected MultiWorkerBase(WorkerTerminate workerTerminate,
                                  StopThread stopThread)
            : base(workerTerminate)
        {
            Guard.NotNull(() => workerTerminate, workerTerminate);
            Guard.NotNull(() => StopThread, stopThread);

            StopThread = stopThread;
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Worker" /> class.
        /// </summary>
        /// <param name="nameFactory">The name factory.</param>
        /// <param name="pauseEvent">The pause event.</param>
        /// <param name="log">The log.</param>
        /// <param name="messageProcessing">The message processing.</param>
        /// <param name="workerTerminate">The worker terminate.</param>
        /// <param name="stopThread">The stop thread.</param>
        public Worker(
            IWorkerNameFactory nameFactory,
            IWorkerWaitForEventOrCancel pauseEvent,
            ILogFactory log,
            IMessageProcessingFactory messageProcessing,
            WorkerTerminate workerTerminate,
            StopThread stopThread)
            : base(workerTerminate, stopThread)
        {
            Guard.NotNull(() => pauseEvent, pauseEvent);
            Guard.NotNull(() => log, log);
            Guard.NotNull(() => nameFactory, nameFactory);

            _pauseEvent  = pauseEvent;
            _log         = log.Create();
            _nameFactory = nameFactory;
            _messageProcessingFactory = messageProcessing;
            IdleStatus = WorkerIdleStatus.Unknown;
        }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Worker" /> class.
        /// </summary>
        /// <param name="nameFactory">The name factory.</param>
        /// <param name="pauseEvent">The pause event.</param>
        /// <param name="log">The log.</param>
        /// <param name="messageProcessing">The message processing.</param>
        /// <param name="workerTerminate">The worker terminate.</param>
        /// <param name="stopThead">The stop thread.</param>
        public Worker(
            IWorkerNameFactory nameFactory,
            IWorkerWaitForEventOrCancel pauseEvent,
            ILogFactory log,
            IMessageProcessingFactory messageProcessing,
            WorkerTerminate workerTerminate,
            StopThread stopThead)
            : base(workerTerminate, stopThead)
        {
            Guard.NotNull(() => pauseEvent, pauseEvent);
            Guard.NotNull(() => log, log);
            Guard.NotNull(() => nameFactory, nameFactory);

            _pauseEvent = pauseEvent;
            _log = log.Create();
            _nameFactory = nameFactory;
            _messageProcessingFactory = messageProcessing;
            IdleStatus = WorkerIdleStatus.Unknown;
        }
Example #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PrimaryWorker" /> class.
        /// </summary>
        /// <param name="nameFactory">The name factory.</param>
        /// <param name="log">The log.</param>
        /// <param name="messageProcessing">The message processing.</param>
        /// <param name="workerTerminate">The worker terminate.</param>
        /// <param name="workerCollection">The worker collection.</param>
        /// <param name="stopThread">The stop thread.</param>
        public PrimaryWorker(
            IWorkerNameFactory nameFactory,
            ILogger log,
            IMessageProcessingFactory messageProcessing,
            WorkerTerminate workerTerminate,
            IWorkerCollection workerCollection,
            StopThread stopThread)
            : base(workerTerminate, stopThread)
        {
            Guard.NotNull(() => nameFactory, nameFactory);
            Guard.NotNull(() => log, log);
            Guard.NotNull(() => messageProcessing, messageProcessing);
            Guard.NotNull(() => workerTerminate, workerTerminate);
            Guard.NotNull(() => workerCollection, workerCollection);

            _log         = log;
            _nameFactory = nameFactory;
            _messageProcessingFactory = messageProcessing;
            _workerCollection         = workerCollection;

            IdleStatus = WorkerIdleStatus.Unknown;
        }
Example #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PrimaryWorker" /> class.
        /// </summary>
        /// <param name="nameFactory">The name factory.</param>
        /// <param name="log">The log.</param>
        /// <param name="messageProcessing">The message processing.</param>
        /// <param name="workerTerminate">The worker terminate.</param>
        /// <param name="workerCollection">The worker collection.</param>
        /// <param name="stopThead">The stop thread.</param>
        public PrimaryWorker(
            IWorkerNameFactory nameFactory,
            ILogFactory log,
            IMessageProcessingFactory messageProcessing,
            WorkerTerminate workerTerminate,
            IWorkerCollection workerCollection,
            StopThread stopThead)
            : base(workerTerminate, stopThead)
        {
            Guard.NotNull(() => nameFactory, nameFactory);
            Guard.NotNull(() => log, log);
            Guard.NotNull(() => messageProcessing, messageProcessing);
            Guard.NotNull(() => workerTerminate, workerTerminate);
            Guard.NotNull(() => workerCollection, workerCollection);

            _log = log.Create();
            _nameFactory = nameFactory;
            _messageProcessingFactory = messageProcessing;
            _workerCollection = workerCollection;

            IdleStatus = WorkerIdleStatus.Unknown;
        }