P
Peter K
Hi, I have a class "QControlThread" which in simplified form is like this:
public class QControlThread
{
private System.Threading.Thread m_thread;
private volatile Boolean m_stopping = false;
public void Start()
{
if (!m_stopping)
{
m_thread = new Thread(this.Worker);
m_thread.Start();
}
}
public void Stop()
{
m_stopping = true;
}
public void Worker()
{
while (!m_stopping)
{
// do work
Thread.Sleep(30000);
}
}
}
What I would like to know is, what if someone calls "Start" multiple times
on the instance of QControlThread? Would I then possibly have multiple
threads which I can't stop or access in any way?
Thanks,
Peter
public class QControlThread
{
private System.Threading.Thread m_thread;
private volatile Boolean m_stopping = false;
public void Start()
{
if (!m_stopping)
{
m_thread = new Thread(this.Worker);
m_thread.Start();
}
}
public void Stop()
{
m_stopping = true;
}
public void Worker()
{
while (!m_stopping)
{
// do work
Thread.Sleep(30000);
}
}
}
What I would like to know is, what if someone calls "Start" multiple times
on the instance of QControlThread? Would I then possibly have multiple
threads which I can't stop or access in any way?
Thanks,
Peter