mono/docker

ThreadPool.SetMinThreads fails if ThreadPool.GetMaxThreads was not called before

Closed this issue · 2 comments

What I'm trying to do

Change the minimum threads number in the threadpool by calling ThreadPool.SetMinThreads(., .)

Code

using System;
using System.Threading;

public static class Test
{
	public static void Main(string[] args)
	{
		int workerThreads, cpThreads;
		ThreadPool.GetMaxThreads(out workerThreads, out cpThreads); // <<<<< HERE

		ThreadPool.SetMinThreads(64, 64);
		ThreadPool.GetMinThreads(out workerThreads, out cpThreads);
		Console.WriteLine("Min threads: {0}, {1}", workerThreads, cpThreads);
	}
}

This code works fine, the output is: Min threads: 64, 64.

Now, if I comment the line with ThreadPool.GetMaxThreads(...), the output is Min threads: 8, 8. The call to SetMinThreads returns false and nothing happens.

Versions

Everything on branch 5 seems affected.

From what I've tested, the following versions work: 4.8.0.524/9d74414 (from Docker Hub), 4.6.2.16/ac9e222 (from Jessie repositories)

The following don't: 5.8.0.127 (from Docker Hub), 5.10.0.160 (from Docker Hub)

This issue was moved to mono/mono#7988

Sorry from the wrong repo :-|