473,788 Members | 2,759 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Killing threads

hi,

I have a Parent child design of a multi threaded application in C#. My issue
is I want the parent class to be able abort or stop the child threads. I
tried abort from the parent, then the child goes to ThreadAbort Requested
state, and not abort state. But when I call the abort method from the child
Thread itself, it throws ThreadAbortExce ption and aborts. Why is it, that
this does not work the same way when being aborted by the Childs parent.

I need the thread to abort in the way it aborts when being called abort by
the thread itself.

Any solution.

Thanks
Amendra
Jul 21 '05 #1
1 1301
Hi Amendra,

I think that, when Abort is invoked from outside, the thread waits for a
suitable moment to Abort...
From the .net help file:
"The thread is not guaranteed to abort immediately, or at all. This
situation can occur if a thread does an unbounded amount of computation in
the finally blocks that are called as part of the abort procedure, thereby
indefinitely delaying the abort. To ensure a thread has aborted, invoke a
Join method on the thread after calling Abort."
--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com

"Amendra" <am*****@virtus a.com> wrote in message
news:uT******** *****@TK2MSFTNG P10.phx.gbl...
hi,

I have a Parent child design of a multi threaded application in C#. My issue is I want the parent class to be able abort or stop the child threads. I
tried abort from the parent, then the child goes to ThreadAbort Requested
state, and not abort state. But when I call the abort method from the child Thread itself, it throws ThreadAbortExce ption and aborts. Why is it, that
this does not work the same way when being aborted by the Childs parent.

I need the thread to abort in the way it aborts when being called abort by
the thread itself.

Any solution.

Thanks
Amendra

Jul 21 '05 #2

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

Similar topics

0
1107
by: Don Garrett | last post by:
I've been developing with external multi-threaded libraries recently. I find it difficult to use the Python prompt to experiment with these libraries because there isn't any way to just shutdown all threads and try things again. If I try to exit the prompt with background threads running, then Python hangs and I have to kill the process to exit. Ctrl C won't do it. Is there some way to brutally kill all background threads? Just for
6
3471
by: Colin Steadman | last post by:
I have created a function to kill all session variables that aren't in a safe list. This is the function - Sub PurgeSessionVariables For Each Item In Session.Contents Select Case Trim(Item) Case "Authenticated" Case "CI_CODE" Case "organisation_description" Case "location_description"
10
9891
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 example: os.system("someapplication.exe") and kill it, if it waits longer than let's say 100 seconds
4
4270
by: muscha | last post by:
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
6
15971
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 I kill it via the name? The trick is I am not in any of these threads I am trying to kill. None of these threads on there own ever die (they are always running in the background). I think I could set up an array when the threads are started,...
10
1428
by: Michael | last post by:
How do I kill the thread of one button with the clicking of another button? ie Private Sub btnEnglish_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnglish.Click System.Threading.Thread.Sleep(200) 'Do This
2
1323
by: mmitchell | last post by:
I have a service that executes a method in a dll. This method spawns several threads. When I stop the service I notice the process doesn't stop right away. I assume the threads that some time to finish. What can I don the the OnStop method to insure all threads are completed before stopping the service? Thanks for any help.
8
12410
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 can drill down into the process, and get the offending Thread's ID (since the only ones that will have the issue have higher User processor Time). But, I can't figure out how to have my .Net app 'kill' or 'suspend' a Thread
18
2545
by: J.K. Baltzersen | last post by:
To whomever it may concern: I am using MS Visual C++ 6.0. I have a process A which instantiates an object C. At a later point the process A creates the thread B. The thread B has access to the object C.
6
1910
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 like a kludge having to spawn whole new processes build in socket communications and kill via explicit OS calls. I can't see that approach scaling particularly well but I guess there's no choice. Does anyone think it likely that the threading...
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10373
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8995
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4074
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2897
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.