Aegis.Threading.WorkerThread.Increase C# (CSharp) Method

Increase() public method

public Increase ( int threadCount ) : void
threadCount int
return void
        public void Increase(int threadCount)
        {
            if (threadCount < 1)
                return;

            lock (this)
            {
                int index = 0;
                if (_threads == null)
                {
                    index = 0;
                    _threads = new Thread[threadCount];
                }
                else
                {
                    index = _threads.Count();

                    //  기존 Thread 객체를 새 배열로 복사
                    Thread[] temp = new Thread[_threads.Count() + threadCount];
                    for (int i = 0; i < _threads.Count(); ++i)
                        temp[i] = _threads[i];

                    _threads = temp;
                }

                for (int i = index; i < index + threadCount; ++i)
                {
                    _threads[i] = new Thread(Run);
                    _threads[i].Name = string.Format("{0} {1}", Name, i);
                }
            }
        }

Usage Example

Beispiel #1
0
        internal static void IncreaseThread(WorkerThread target, int threadCount)
        {
            int increaseCount = threadCount - target.ThreadCount;

            if (increaseCount < 1)
            {
                return;
            }

            target.Increase(increaseCount);
            target.Start();
        }
All Usage Examples Of Aegis.Threading.WorkerThread::Increase