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

Thread Abort?

I need to have an asynch thread abort itself. Something akin to a STOP. The
thread that spawned it cannot access it so it must done within the thread.

Chip
Sep 13 '06 #1
3 1872
Best way is probably to have a field visible to the thread thats not
controlled by the async thread and have the asyn thread check if the value
signifies abort. Perhaps a value available in Context, session or
application that the async thread can periodically look at.

Regards

John Timney (MVP)
http://www.johntimney.com
"Chip" <ch**@intradata.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>I need to have an asynch thread abort itself. Something akin to a STOP. The
thread that spawned it cannot access it so it must done within the thread.

Chip

Sep 13 '06 #2
This approach has the parent process ending the thread. The test is in the
thread itself so it needed to be a self-abort. There doesn't seem to be a
good way to do it based on what I've been able to research, so since the
easy way out is not there, I restructured the code so I could just use "exit
sub".

Thanks for the reply,

Chip
"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote in message
news:IL********************@eclipse.net.uk...
Best way is probably to have a field visible to the thread thats not
controlled by the async thread and have the asyn thread check if the value
signifies abort. Perhaps a value available in Context, session or
application that the async thread can periodically look at.

Regards

John Timney (MVP)
http://www.johntimney.com
"Chip" <ch**@intradata.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>>I need to have an asynch thread abort itself. Something akin to a STOP.
The thread that spawned it cannot access it so it must done within the
thread.

Chip


Sep 13 '06 #3
If you abort an asnc thread with something like thread abort I believe it
throws an unhandled exception, which can leave your objects in an ustable
state, hence my suggestion to use a controller value to terminate and exit
the thread cleanly. If you've managed to get it running to exit sub and die
cleanly then stick with it.

Regards

John Timney (MVP)
http://www.johntimney.com
"Chip" <ch**@intradata.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
This approach has the parent process ending the thread. The test is in the
thread itself so it needed to be a self-abort. There doesn't seem to be a
good way to do it based on what I've been able to research, so since the
easy way out is not there, I restructured the code so I could just use
"exit sub".

Thanks for the reply,

Chip
"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote in message
news:IL********************@eclipse.net.uk...
>Best way is probably to have a field visible to the thread thats not
controlled by the async thread and have the asyn thread check if the
value signifies abort. Perhaps a value available in Context, session or
application that the async thread can periodically look at.

Regards

John Timney (MVP)
http://www.johntimney.com
"Chip" <ch**@intradata.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>>>I need to have an asynch thread abort itself. Something akin to a STOP.
The thread that spawned it cannot access it so it must done within the
thread.

Chip



Sep 13 '06 #4

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

Similar topics

14
by: Daisy | last post by:
From this page: http://www.c-sharpcorner.com/2/mt_beginner1.asp Thread class's Abort method is called to kill a thread permanently. Make sure you call IsAlive before Abort. if (...
7
by: Morris | last post by:
I want to abort a running thread, so I call MyThread.abort() function. My problem is this thread runs "almost" like a while(true) loop and I don't want the Abort() function interrupts the thread at...
20
by: Doug Thews | last post by:
I ran into an interesting re-pain delay after calling the Abort() method on a thread, but it only happens the very first time I call it. Every time afterward, there is no delay. I've got a...
18
by: Urs Vogel | last post by:
Hi I wrote an application server (a remoting sinlgeton), where processes must be stopped in very rare cases, done thru a Thread.Abort(). Occasionally, and only after a Thread.Abort(), this...
1
by: benmorganpowell | last post by:
I have a small windows service which connects to a POP3 server at defined intervals, scans the available messages, extracts the required information and inserts the data into a SQL database. I am...
2
by: Mark Denardo | last post by:
I'm trying to abort a suspended thread, but I get a ThreadStateException: An unhandled exception of type 'System.Threading.ThreadStateException' occurred in mscorlib.dll Additional...
6
by: Joe HM | last post by:
Hello - I have a function that calls Thread.Abort() to stop a thread in a _Closed() Method of a GUI. The thread contains a blocking call on a TCP socket and that is the easiest way to stop...
23
by: Boltar | last post by:
Hi I'm writing a threading class using posix threads on unix with each thread being run by an object instance. One thing I'm not sure about is , if I do the following: myclass::~myclass() {...
5
by: andrew | last post by:
Hi, I have the following issue with the Thread.Abort(): The main thread creates a worker thread which waits on a process termination. void ThreadProc() { Process proc =...
6
by: mehdi | last post by:
Hi folks, You know, the Thread class has got a method named Abort which according to the msdn: "Raises a ThreadAbortException in the thread on which it is invoked, to begin the process of...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
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.