473,549 Members | 2,741 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

aborting thread while waiting for callback

In a multi-threaded application, say a worker thread makes an asynchronous
call and specifies a callback method. But before the callback is executed,
the thread is aborted by its creator. What is the expected behavior for
this scenario? Does the thread stay alive until the callback is executed? If
an exception is thrown, can it be caught?

I posted this message last week, but got no response. I am really hoping
someone can help me with this. Thanks.
Nov 15 '05 #1
1 2610
The lifetime of the thread is not affected by the "desire" of other threads
to deliver events, notifications, or callbacks to it. If you kill the
thread, and it leaves its threadfunc, then it is gone. There is a
distinction to be made here between the thread, and a class object instance
that may be associated with the thread - the thread can be gone while the
object instance is still valid.

The actual behavior will really vary based upon what asynchronous method you
called. You can write your own asynchronous objects and make it handle the
callback in any manner you desire. If you have invoked a runtime routine
then you will get whatever behavior they specify.

In general the rule is that once you initiate an asynchronous call unless
there is a mechanism for aborting or canceling the transaction then the
callback will be called regardless of what the original invoking thread has
done. There is also a distinction to be made between a worker thread
terminating/aborting versus the object instance used as the context in the
call. The worker thread may terminate while the object that was associated
with it may still be valid.

It may also be the case that the callback is delivered on an arbitrary
thread (e.g. one of the threads in the ThreadPool), in which case it is the
object instance (the context) that is important, not the thread itself that
it is delivered on. In fact, I would expect this to be how it was delivered
if the async call was initiated from a worker thread, as there is no UI
mechanism it could use to deliver the callback on a specific thread.
Regardless, it is up to you the developer to ensure that required thread
safety issues are dealt with.

It would help if you could specify the type of worker thread (does it have a
UI or not, background or foreground), and the actual async call you are
planning on using.

"johnny" <so*****@somewh ere.com> wrote in message
news:Ou******** ******@TK2MSFTN GP09.phx.gbl...
In a multi-threaded application, say a worker thread makes an asynchronous
call and specifies a callback method. But before the callback is executed,
the thread is aborted by its creator. What is the expected behavior for
this scenario? Does the thread stay alive until the callback is executed? If an exception is thrown, can it be caught?

I posted this message last week, but got no response. I am really hoping
someone can help me with this. Thanks.

Nov 15 '05 #2

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

Similar topics

0
2249
by: johnny | last post by:
I'm hoping someone can help me better understand the scenario below In a multi-threaded application, say a worker thread makes an asynchronous call and specifies a callback method. But before the callback is executed, the thread is aborted by its creator. What is the expected behavior for this scenario? Does the thread stay alive until...
8
2380
by: Mountain Bikn' Guy | last post by:
I'm using async delegate calls. I would like to re-enter my initial thread after the callback. (I'm not using UI controls, so Control.Invoke is not the solution.) How can I manually implement behavior like Control.Invoke? How can I re-enter my initial thread? Any suggestions? Thanks! Mountain I already searched Google Groups and found...
4
5421
by: Matthew Groch | last post by:
Hi all, I've got a server that handles a relatively high number of concurrent transactions (on the magnitude of 1000's per second). Client applications establish socket connections with the server. Data is sent and received over these connections using the asynchronous model. The server is currently in beta testing. Sporadically over the...
8
3508
by: MuZZy | last post by:
Hi, Could someone pls help me here: If i use async sockets in the separate thread like this: void ThreadFunction() { ..... 1. MySocket.BeginAccept(AsyncCallBack(OnConnectRequest), MySocket);
2
2022
by: Xarky | last post by:
Hi, I am writing a small program, that makes use of threads. Now in on of the threads I have a critical section, where I am using the Monitor to handle this. *** Thread_1 *** started for(...) { ....doing some work Monitor.Enter(Thread_1);
7
6796
by: archana | last post by:
Hi all, I am having application in which i am doing asynchronous call.I am using manualresetevent to wait for asynchronous call to complete. I want to stop asynchronous call after certain period of time. I want something like thread.abort for aborting aynchronous call. Can someone tell me way of aborting asynchronous call.
5
3782
by: admin | last post by:
ok This is my main. Pretty much it goes through each category and starts up 4 worker threads that then ask for groups to gether from. My problem is that when the thread gets done it keeps the mysql connections open so I end up with quite a few at the end. Is there a different way that I should do this? class Program { static string...
2
3532
by: Amit Dedhia | last post by:
Hi I am developing a scientific application which has moderate level image processing involved. In my application, there is a main application form which invokes another form. When this form is running, a timer function keeps executing every 250ms. The timer function does some real time data processing and generates a bitmap which needs...
4
15869
by: Mufasa | last post by:
Is there any way to force a thread to abort and really have it abort? I have a thread that every once in a while gets hung to so I kill it. Problem is I have a thread that every once in a while gets stuck (I'm working on why that happens) and I want to kill it. I do a thread.abort and the status becomes abortrequested but never actually goes...
0
7520
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...
0
7957
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6043
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...
1
5368
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...
0
5088
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...
0
3500
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1941
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
1
1059
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
763
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...

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.