M
Matt
Ok, this is probably a simple and stupid question, but its giving me hell.
Lets say that this is my app
public class myapp : System.Windows.Forms.Form
{
public myapp()
{
}
private void btnGo_Click(blah, blah)
{
ThreadStuff ts = new ThreadStuff();
}
}
public class ThreadStuff
{
Thread tt;
public ThreadStuff()
{
tt = new Thread(new ThreadStart(this.GoDoSomething));
tt.Start();
}
private void GoDoSomething()
{
while(true)
{
Thread.Sleep(new timespan(0,0,10);
}
}
}
I know the app does nothing, but stay with me
When I close the app the process is still running in task manager. What do
I need to do to clean up the thread and abort it? Shouldnt the instance of
ThreadStuff get disposed of and does that not kill all the objects including
the threat tt?
Obviously, Im doing something wrong. Let me know what the best way to kill
a thread that is running whenever the application is closed.
Thanks for the help.
Lets say that this is my app
public class myapp : System.Windows.Forms.Form
{
public myapp()
{
}
private void btnGo_Click(blah, blah)
{
ThreadStuff ts = new ThreadStuff();
}
}
public class ThreadStuff
{
Thread tt;
public ThreadStuff()
{
tt = new Thread(new ThreadStart(this.GoDoSomething));
tt.Start();
}
private void GoDoSomething()
{
while(true)
{
Thread.Sleep(new timespan(0,0,10);
}
}
}
I know the app does nothing, but stay with me
When I close the app the process is still running in task manager. What do
I need to do to clean up the thread and abort it? Shouldnt the instance of
ThreadStuff get disposed of and does that not kill all the objects including
the threat tt?
Obviously, Im doing something wrong. Let me know what the best way to kill
a thread that is running whenever the application is closed.
Thanks for the help.