473,385 Members | 1,907 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,385 software developers and data experts.

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 ThreadAbortException 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
Nov 15 '05 #1
1 2510
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*****@virtusa.com> wrote in message
news:uT*************@TK2MSFTNGP10.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 ThreadAbortException 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

Nov 15 '05 #2

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

Similar topics

0
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...
6
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)...
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...
4
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...
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...
10
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 ...
2
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...
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...
18
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...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.