"There are not enough free threads in ThreadPool to complete the operation."

When booting using multiple threads, I received the following error message:

ThreadPool did not have enough free threads to complete the operation.

Should I try to change the default settings for threadpool in .net and how to do it?

+3
source share
4 answers

ThreadPool - ( : ); - ? TPL Task[<T>] , IO - Begin*/End* , ThreadPool.

, async ; (, ) ?

: ThreadPool ( Thread); Thread s

+9

, - . , , , , .

int workerThreads, cmpThreads;
ThreadPool.GetAvailableThreads(out workerThreads, out cmpThreads);

.

:

- .NET

+3

, , , , .

 public static void ExpandThreadPool(int minThreads,int maxThreads)
    {
        int workerThreads, cmpThreads;

        ThreadPool.GetMaxThreads(out workerThreads, out cmpThreads);
        if (workerThreads < maxThreads)
        {
            workerThreads = maxThreads;
        }
        ThreadPool.SetMaxThreads(workerThreads, cmpThreads);

        ThreadPool.GetMinThreads(out workerThreads, out cmpThreads);
        if (workerThreads < minThreads)
        {
            workerThreads = minThreads;
        }
        ThreadPool.SetMinThreads(workerThreads, cmpThreads);

    }
+1

AspNetServer:

if (Thread.GetDomain().GetData(".appDomain") == null)
{
    Thread.GetDomain().SetData(".appDomain", new object());
}

. System.Net.NclUtilities.IsThreadPoolLow:

if (ComNetOS.IsAspNetServer)
{
    return false;
}

System.Net.ComNetOS .ctor():

IsAspNetServer = Thread.GetDomain().GetData(".appDomain") != null;
+1

All Articles