473,322 Members | 1,352 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Killing all thread when closing applications.

Hi,

I spawns a number of background threads while creating a windows forms
application. I noticed that when I quit the application or calling
Application.Exit, it hasn't really stop. Is there a quick way to say
"terminate all threads and quit"?

thanks,

/m
Nov 15 '05 #1
4 4237
> I spawns a number of background threads while creating a windows forms
application. I noticed that when I quit the application or calling
Application.Exit, it hasn't really stop. Is there a quick way to say
"terminate all threads and quit"?


Set property isBackground to true.

Foreground and Background Threads
A foreground thread runs indefinitely, while a background thread
terminates once the last foreground thread has stopped. You can use
the IsBackground property to determine or change the background
status of a thread.

Nov 15 '05 #2
Hi,

I assumed he does this already (... a number of background threads).

Miha

"Vladimir Bezugly" <vb**@inbox.ru> wrote in message
news:sl*****************@fluffy.isd.dp.ua...
I spawns a number of background threads while creating a windows forms
application. I noticed that when I quit the application or calling
Application.Exit, it hasn't really stop. Is there a quick way to say
"terminate all threads and quit"?


Set property isBackground to true.

Foreground and Background Threads
A foreground thread runs indefinitely, while a background thread
terminates once the last foreground thread has stopped. You can use
the IsBackground property to determine or change the background
status of a thread.

Nov 15 '05 #3
As someone else pointed out, make sure all your background threads are
marked as background. When the appdomain is exiting the runtime goes to
great lengths to unwind all threads and terminate. One thing to watch for
are threads that are blocked in unmanaged code - the runtime has no easy way
of forcing them to terminate.

Other then that there is no quick way to terminate all the threads.
"muscha" <mu****@no.spam.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,

I spawns a number of background threads while creating a windows forms
application. I noticed that when I quit the application or calling
Application.Exit, it hasn't really stop. Is there a quick way to say
"terminate all threads and quit"?

thanks,

/m

Nov 15 '05 #4
> As someone else pointed out, make sure all your background threads are
marked as background. When the appdomain is exiting the runtime goes to
great lengths to unwind all threads and terminate. One thing to watch for
are threads that are blocked in unmanaged code - the runtime has no easy way of forcing them to terminate.
Ah yes, after some debugging I found out that there are references to
unmanaged code threads that are still running.
Other then that there is no quick way to terminate all the threads.
Thanks,

/m



"muscha" <mu****@no.spam.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,

I spawns a number of background threads while creating a windows forms
application. I noticed that when I quit the application or calling
Application.Exit, it hasn't really stop. Is there a quick way to say
"terminate all threads and quit"?

thanks,

/m


Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Hari Prasad | last post by:
I wrote an application where I am trying to kill a parent frame with out killing the child one. I have created a frame (F1) and if I click a button on F1 I am getting a new frame (F2). Now, if...
2
by: John E. Hadstate | last post by:
Please forgive the heavy cross-posting and feel free to delete inappropriate groups when you reply. I am really at a loss and hope someone has an answer for my problems. Environment: Redhat...
10
by: Jacek Pop³awski | last post by:
Hello. I am going to write python script which will read python command from socket, run it and return some values back to socket. My problem is, that I need some timeout. I need to say for...
5
by: Saurabh Sharma | last post by:
Hi I have made a Windows Form and in it few calculations and processos are running. When i close the form the process continues to run until that particular function in finished. I cant use...
6
by: Bob Day | last post by:
VS 2003, vb.net ... Is there an easy way to kill from the main form all threads running ? Is there a thread collection to iterate through to kill each one? I know each thread's name, so could...
39
by: clintonG | last post by:
This is not about starting a fight but an observation that seems to be proving itself on its own merit and is therefore simply a point of conjecture. I did not get serious about writing software...
8
by: Rob | last post by:
Hello, I've got an issue where a process in a third party application has a dll which while exiting sort of freezes and runs away with processor cycles. i've written a block of code so that I...
0
by: Maqbool | last post by:
Hi, I am intantiating thread that do more extensive work, i.e. executing query on FoxPro 2.6 through ODBCDataAdapter with VisualFoxPro driver. Since the query executing is Complex and navigating...
6
by: Roger Heathcote | last post by:
sjdevnull@yahoo.com wrote: <snip> Fair point, but for sub processes that need to be in close contact with the original app, or very small functions that you'd like 100s or 1000s of it seems...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.