コード例 #1
0
ファイル: ThreadPool.cs プロジェクト: masums/clawPDF
        /// <summary>
        ///     Starts the first thread from the thread queue
        /// </summary>
        private void StartThread()
        {
            Logger.Trace("COM: Starting thread...");
            _isThreadRunning  = true;
            _conversionThread = ThreadQueue.Dequeue();

            _conversionThread.OnThreadFinished += ConversionThreadFinished;
            _conversionThread.Start();
        }
コード例 #2
0
#pragma warning restore CS0067

        /// <summary>
        ///     Adds and starts a synchronized thread to the thread list. The application will wait for all of these to end before
        ///     it terminates
        /// </summary>
        /// <param name="thread">A thread that needs to be synchronized. This thread will not be automatically started</param>
        public void StartSynchronizedThread(ISynchronizedThread thread)
        {
            if (_isShuttingDown)
            {
                _logger.Warn("Tried to start thread while shutdown already started!");
                return;
            }

            _logger.Debug("Adding thread " + thread.Name);

            _threads.Enqueue(thread);

            if (thread.ThreadState == ThreadState.Unstarted)
            {
                thread.Start();
            }
        }
コード例 #3
0
        /// <summary>
        ///     Adds and starts a synchronized thread to the thread list. The application will wait for all of these to end before
        ///     it terminates
        /// </summary>
        /// <param name="thread">A thread that needs to be synchronized. This thread will not be automatically started</param>
        public void StartSynchronizedThread(ISynchronizedThread thread)
        {
            lock (LockObject)
            {
                if (_isShuttingDown)
                {
                    _logger.Warn("Tried to start thread while shutdown already started!");
                    return;
                }

                _logger.Debug("Adding thread " + thread.Name);

                _threads.Add(thread);
                thread.OnThreadFinished += thread_OnThreadFinished;

                if (thread.ThreadState == ThreadState.Unstarted)
                {
                    thread.Start();
                }
            }
        }