Hi,
how does one end a thread when it is done eg i have a program the when u press a button it starts a thread, this thread performs a set of instructions and then when it is done it it finished how do you end a thread then when the code is done, thus allowing the user to perform mulitple queries?
Thanks

Recommended Answers

All 3 Replies

Unless it's in an infinite loop, it ends when the method you used to start the thread is done.

oh sweet
thanks thought that might be the case but wasn't sure

You should check out the. Net 4 Framework an the addition of Task. They did a really nice job with cancelling a threat orderly without the need for Abort.

The reason I say this is for long running queries, you have to wait until they finish before thread cleanup really happens. CancellationTokenResource, you have complete control to stop gracefully without raising an exception.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.