I start a new thread. When the application exits, I want to be able to terminate the thread.
[CODE]Thread qs = new Thread(new ThreadStart(queryserver));
qs.Start();[/CODE]
Also, if you exit your application via Environment.Exit(), all threads automatically terminate
It's worth noting that your thread's method will throw an exception when the thread is terminated if it still running ( eg, quit while processing something ).
So:
[code]
try
{
//code
}
catch( Threading.ThreadAbortException e )
{
}
[/code]
Or whatever the exception is.
Get a mod to close it. :v:
Hahaha, that was good.
Cut it by the cord
Usually it's better to set some variable that tell the thread to stop instead of forcing it.
[QUOTE=noctune9;20848548]Get a mod to close it. :v:[/QUOTE]
I wanted to say this :v:
[QUOTE=Ortzinator;20852241]Usually it's better to set some variable that tell the thread to stop instead of forcing it.[/QUOTE]
This and then wait for the thread to be closed.
What language are you using?
[QUOTE=Chad Mobile;20852173]Hahaha, that was good.[/QUOTE]
Yeah, I know, he gave me a Non copynpasta snippet.
[QUOTE=Borsty;20853888]This and then wait for the thread to be closed.
What language are you using?[/QUOTE]
C#, as you can see by the thread icon. (no pun intended)
[QUOTE=Encryption;20917392]Yeah, I know, he gave me a Non copynpasta snippet.[/QUOTE]
:cawg:
keep 'em coming