Challenging Multithread Question 500points
Posted on 2004-10-07
I am creating a Multithreaded C# Application. The application will query a database for "jobs" to execute. If it finds available jobs it will create a new "Job Object" (based on parameters supplied from the dataset returned from the query) and a fresh worker thread for each job to be run. This all works great. I know that when the method (doSomeWork in the below example) that the new thread calls exits the thread terminates.
Thread workthread = new Thread(new ThreadStart(doSomeWork));
What I need to accomplish is keeping track of all currently running threads. When the thread is created it will increment an int variable, and decrement that variable when the thread exits. I would also like to uniquely identify each thread. So I can have, say a list box on a Winform showing currently executng threads. So, essentially how do I monitor/track/label existing threads?
500 Points for some help.