My program starts 5 different threads when it is opened. One or more of them is not stopping correctly and is causing my program to remain alive even after the main form has closed. Before I go through trying to find which one is doing it is there some way I can just force every thread to immediately stop when the program is starting to close? I know it's bad technique to force something to stop but none of the threads are actually doing anything that could hurt if it's interrupted. All of them check each second to see if they need to do something so most of the time they're doing nothing at all.
WildBamaBoy
19
Junior Poster
Recommended Answers
Jump to PostDo you have references to the threads? If so, call Thread.Abort() on them. If not before you start the thread set it as a background thread (Thread.IsBackground = true). Background threads cannot prevent the main thread from closing (like your forground threads are doing).
Jump to PostMy program starts 5 different threads when it is opened. One or more of them is not stopping correctly and is causing my program to remain alive even after the main form has closed. Before I go through trying to find which one is doing it is there some way …
Jump to PostMy program starts 5 different threads when it is opened. One or more of them is not stopping correctly and is causing my program to remain alive even after the main form has closed. Before I go through trying to find which one is doing it is there some way …
Jump to PostOups..I'm working with Background Workers not Threads, I call them both threads. My bad. :D
hey wildBamaBoy backGround worker threads background property "should" set to true therefore ending once your main thread ends...
can you provide the code you're running?
Jump to PostBackground threads shouldn't stop your program from closing so there is something else going on. Have you tried using the VS multi-thread debugger to see what's going on?
All 19 Replies
Momerath
1,327
Nearly a Senior Poster
Featured Poster
d.allen101
0
Newbie Poster
d.allen101
0
Newbie Poster
WildBamaBoy
19
Junior Poster
d.allen101
0
Newbie Poster
WildBamaBoy
19
Junior Poster
WildBamaBoy
19
Junior Poster
Momerath
1,327
Nearly a Senior Poster
Featured Poster
WildBamaBoy
19
Junior Poster
WildBamaBoy
19
Junior Poster
Momerath
1,327
Nearly a Senior Poster
Featured Poster
WildBamaBoy
19
Junior Poster
Momerath
1,327
Nearly a Senior Poster
Featured Poster
d.allen101
0
Newbie Poster
WildBamaBoy
19
Junior Poster
Momerath
1,327
Nearly a Senior Poster
Featured Poster
d.allen101
0
Newbie Poster
WildBamaBoy
19
Junior Poster
WildBamaBoy
19
Junior Poster
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.