Below you will find a simple, complete code sample for multithreading in C# using the ThreadPool class. This sample uses a simple counter to track the number of threads that are active to prevent the application from closing before all threads have completed. Although there are other ways to force a method to wait for all threads to complete before exiting, using a static counter allows you to create a separate method to determine when the application is allowed to exit. This is useful for handling OnStop events on windows services. Within the StopProcessing() method you could also set a flag that would prevent your application from creating new threads.