TsgcWebSocketServerProperties › ThreadPool

ThreadPool Property

Enables a thread pool that recycles worker threads instead of destroying them when connections close.

Syntax

public bool ThreadPool { get; set; }

Default Value

False

Remarks

When ThreadPool is True, threads that finish serving a connection are returned to a pool instead of being destroyed; they are marked inactive and consume no CPU cycles until reused, which dramatically reduces the cost of short-lived connections. Tune ThreadPoolOptions (MaxThreads, PoolSize) to control how many threads may be created. The thread pool is not compatible with IOCP: do not enable both ThreadPool and IOHandlerOptions.IOHandler=iohIOCP at the same time.

Example


oServer = new TsgcWebSocketServer();
oServer.ThreadPool = true;
oServer.ThreadPoolOptions.PoolSize = 32;
oServer.Active = true;

Back to Properties