After searching in questions and some search queries, I still do not get it.
I know that you can check if one thread is working with the Thread.isAlive () method, but I want to check if some other “FooThread” works between all running threads from the current process and If not, call the method that will run his.
//somewhere in the code, on another Project/DLL inside solution private void FooThreadCaller() { Action act = () => fooFunction(); Thread t = new Thread(new ThreadStart(act)); t.Name = "FooThread"; t.Start(); } //... Process proc = System.Diagnostics.Process.GetCurrentProcess(); ProcessThreadCollection threads = proc.Threads; bool ThreadExists = false foreach (ProcessThread item in threads) { // if item.Name == "FooThread", then ThreadExists = true... // so, if !ThreadExists then call FooThreadCaller() and so on. } //...
code>
Since the ProcessThread class does not have the "Name" property (for example, System.Threading.Thread), but only the ID, and I know only the name of the thread ("FooThread"), and not the identifier, how can I check if "FooThread" works / alive?
Thank you in advance
Cezar lamann
source share