check is thread is still running
I have a class that is called from a page in a new thread and I have property on the class to check if the thread is still running. Here is the scenario
I have a class ..................
public void work()
I have property on this class to check if a spawn thread is running
public static bool IsThreadRunning()
isRunning = false;
I have a method on the class that is called from an aspx page in a new thread. I set the isrunning flag to true
public void dowork()
isRunning = true;
I call the method from page
var work = new work();
Thread newThread = new Thread(new ThreadStart(work.dowork()));
I and redirect to a status page
On status page I check the if thread is running by the property IsThreadRunning() like this
But is always returning false even though I know that the thread is running - what is wrong with this?