473,811 Members | 2,190 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Aborting async execution started by BeginInvoke?


When the BeginInvoke method of a delegate is called, the
execution of the delegate is in another thread. (I'm not
sure if an entirely new thread is created, or if a "sleeping"
thread is used.)

Now, is there any way to stop this execution?

Suppose there are some really heavy calculations (or whatever)
that needs to be performed every time indata change. Assume
it takes somewhere around 10-60 seconds to do these calculations.

An obvious way to implement this is to call the BeginInvoke of
a delegate (in which all the work is done) and get a call to a
callback when the calculations are finished. (So you e.g. don't
lock the GUI and network communications for the 10-60 seconds.)

However, let's say indata can change before the calculations are
finished, and then you want to stop the first "calculatio n batch"
and start a second with this new indata.

Is this possible to do? The IAsyncResult returned by BeginInvoke
doesn't seem to have any "Abort" method, but is it possible to
derive the corresponding Thread from the IAsyncResult, and call
the Abort method of this Thread? (Or would such a technique mess
things up, e.g. perhaps kill all the outstanding current and
subsequent executions of calls to BeginInvoke?)

/Gomaw

Nov 15 '05 #1
1 3139
Metxtli
1 New Member
Hi,

I have the same question, there are any solution??

regards,

Metxtli
Apr 28 '06 #2

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

Similar topics

8
2005
by: Dave | last post by:
I'm using the BeginInvoke method of a delegate to invoke a thread asynchronously and then use the EndInvoke to retrieve the value. This works wonderfully until a Serviced Component is added to the mix. When the Serviced Component is invoked with BeginInvoke, the code hangs for the duration of the call rather than running async. Any ideas? Sample code below: Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As...
4
3870
by: Vlad | last post by:
I have implemented an asyncrhonous execution of a method using the delegate's BeginInvoke() I am trying to spin multiple worker threads in a thread pool. Here is the code: TestProcess process = new TestProcess(TestProcess); process.BeginInvoke(args,null,null); private void TestProcess(args) {
10
2967
by: Shawn Meyer | last post by:
Hello - I am trying to write a class that has an async BeginX and EndX, plus the regular X syncronous method. Delegates seemed like the way to go, however, I still am having problems getting exactly what I want. Here are my goals 1. I would like the IAsyncResult that is returned by the Begin function to be able to be waited on or polled to check for completion. 2. The Begin function would take a callback, and the async process would
1
2764
by: eminemabcd | last post by:
Hi, I encountered a problem trying to write a code that does the following: 1. Main GUI thread invokes a delegate using BeginInvoke. 2. A secondery thread (from the application's managed thread pool) starts executing and BeginInvoke returns. 3. Main GUI thread remains responsive while the secondery thread executes in the background. 4. Secondery thread finishes its execution. 5. Main GUI thread is notified of the completion of the...
4
4397
by: Dennis Sjogren | last post by:
Greetings! First, I'm not 100% sure where to post this question. I use VB.NET for this project, but it's really a design question (a question on which method to use when solving this problem). In this medium sized (30 or so forms) application, our users have requested a more visual notification of when the client (this app) is communicating with the server, or for other lenghty processes. Disabling the current form and changing the...
1
2287
by: jonathan | last post by:
I need to create a webpage that asynchronously loads a series of user controls onto a page. If the user control take longer than X seconds to load it should display an error message in it place. The rest of the page should continue to load whilst the seperate user control threads are loading. What is the correct way of doing this? I've created a delegate for loading the user control sand called
7
6807
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.
9
5744
by: BartMan | last post by:
Greetings, I am trying to fire aysnc events in c++/clr, and I can't seem to get it to work. It seems to work fine in c#, but when I try c++/clr, I can't seem to get it to compile in the c++/clr class. I.) Event Testing in C#, which works fine: public class CSharpEventTest {
12
3544
by: Tomaz Koritnik | last post by:
Is it possible to asynchronously call a method from worker thread so that this method would execute in main-thread? I'm doing some work in worker thread and would like to report progress to main thread to update some controls. But I'd like to do that asynchronously so that worker thread would not block until main thread finished updating and refreshing controls which take some time. Using invoke is out since it blocks worker thread until...
0
9728
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
9605
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10648
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
9205
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
7670
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
6890
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
5554
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4339
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

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.