G
Guest
Hi,all
I am confused about thread, Please help me,
I have two class, Calss One and Class Two,
Class One Has Class Two instance,Class Two has a Thread.
well, I want to quit Class One,Do I need to end Calss Two thread before I
end Class One instance?
If I should end Thread before I quit Class One,
How to wait for the thread end?
here is the source:
class one
{
private Two two;
public one()
{
two = new Two();
}
public void quit()
{
this.two.ThreadQuit = true;
//here wait for two thread end????
....
....
}
}
calss Two
{
private bool bQuit = false;
public Two()
{
Thread = new Thread(new ThreadStart(Threadproc))
}
private void Threadproc
{
while(true)
{
if(bQuit)
break;
DoSomthing();
}
}
public bool ThreadQuit
{
set
{
this.bQuit = value
}
}
}
Thanks
I am confused about thread, Please help me,
I have two class, Calss One and Class Two,
Class One Has Class Two instance,Class Two has a Thread.
well, I want to quit Class One,Do I need to end Calss Two thread before I
end Class One instance?
If I should end Thread before I quit Class One,
How to wait for the thread end?
here is the source:
class one
{
private Two two;
public one()
{
two = new Two();
}
public void quit()
{
this.two.ThreadQuit = true;
//here wait for two thread end????
....
....
}
}
calss Two
{
private bool bQuit = false;
public Two()
{
Thread = new Thread(new ThreadStart(Threadproc))
}
private void Threadproc
{
while(true)
{
if(bQuit)
break;
DoSomthing();
}
}
public bool ThreadQuit
{
set
{
this.bQuit = value
}
}
}
Thanks