コード例 #1
0
ファイル: ThreadPool.cs プロジェクト: masums/clawPDF
        /// <summary>
        ///     Adds a new thread to the thread pool
        /// </summary>
        /// <param name="aThread">The thread to be added</param>
        public void AddThread(ISynchronizedThread aThread)
        {
            if (aThread.ThreadState == ThreadState.Running)
            {
                aThread.Abort();
            }

            Logger.Trace("COM: Pushing new thread into the thread queue.");
            ThreadQueue.Enqueue(aThread);

            if (Count != 1 || _isThreadRunning)
            {
                return;
            }

            Logger.Trace("COM: Thread was added therefore the corresponding event is fired.");
            OnThreadAdded?.Invoke(new object(), new EventArgs());
        }
コード例 #2
0
ファイル: ThreadPool.cs プロジェクト: xulong2005/PDFCreator
        /// <summary>
        ///     Adds a new thread to the thread pool
        /// </summary>
        /// <param name="aThread">The thread to be added</param>
        public void AddThread(ISynchronizedThread aThread)
        {
            if (aThread.ThreadState != ThreadState.Unstarted)
            {
                throw new ArgumentException(nameof(aThread));
            }

            Logger.Trace("COM: Pushing new thread into the thread queue.");
            ThreadQueue.Enqueue(aThread);

            if (Count != 1 || _isThreadRunning)
            {
                return;
            }

            Logger.Trace("COM: Thread was added therefore the corresponding event is fired.");
            OnThreadAdded?.Invoke(this, new EventArgs());
        }