/// <summary> /// Maksimum iþçi thread sayýsýný geçmeyecek þekilde yeni iþçi thread baþlatýr. /// Eðer havuz kapatýlýyor olarak iþaretlendi ise hiç iþçi thread baþlatmaz. /// </summary> /// <param name="threadsCount">Baþlatýlacak iþçi thread sayýsý.</param> private void TryStartNewThreads(int threadsCount) { OnWorkerThreadPoolTryingToStartNewWorkerThreads(new WorkerThreadPoolTryingToStartNewWorkerThreadsEventArgs(threadsCount)); // Ýþçi thread listesi üzerinde iþlem yapýyoruz, dolayýsýyla baþka thread'lerin listeyi // deðiþtirmesini engellemek için listeyi kilitliyoruz. lock (m_WorkerThreads) { // Eðer havuz kapatýlýyor olarak iþaretlendi ise metoddan çýkýyoruz. if (m_IsShuttingdown) { return; } for (int i = 0; i < threadsCount; i++) { // Eðer mevcut iþçi thread sayýsý maksimum iþçi thread sayýsýndan fazla oldu ise metoddan çýkýyoruz. if (m_WorkerThreads.Count >= m_MaxWorkerThreads) { return; } // Havuz numarasý ve thread numarasýna göre bir thread ismi belirliyoruz. string threadName = string.Format(CultureInfo.CurrentCulture, "Labo WTP #{0} Thread #{1}", s_WorkerThreadPoolIdCounter, ++m_WorkerThreadIdCounter); WorkerThread workerThread = new WorkerThread(this, m_WorkItemQueue, threadName, false); // Yarattýðýmýz iþçi thread'i iþçi thread listesine ekliyoruz. m_WorkerThreads.Add(workerThread); OnWorkerThreadPoolStartingNewWorkerThread(new WorkerThreadPoolStartingNewWorkerThreadEventArgs(m_WorkerThreads.Count, workerThread)); // Ýþçi thread'i hemen baþlatýyoruz. workerThread.Start(); } } }