Skip to content

RipcordSoftware/ApplicationThreadPool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Build status

ApplicationThreadPool

An application thread pool for .NET or Mono.

Features:

  • Set the number of threads in the pool at runtime
  • Gives all the threads a useful name
  • Create as many pools as you like
  • Worker threads can be foreground or background
  • You can set the thread priority of the workers

Example

The short example below can be found in the examples directory in this repo.

static void Main(string[] args)
{
    var pool = new ApplicationThreadPool("test", 16, 1024, true);

    var activeThreads = pool.MaxThreads;
    for (var i = 0; i < pool.MaxThreads; ++i)
    {
        pool.QueueUserWorkItem(o => { Console.WriteLine("Hello"); Interlocked.Decrement(ref activeThreads); });
    }

    while (activeThreads > 0)
    {
        Thread.Sleep(0);
    }

    Console.WriteLine("Finished");
    Console.ReadLine();
}

Releases

No releases published

Packages

No packages published

Languages