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

Home Posts Topics Members FAQ

about BeginInvoke and EndInvoke

Hi All,
There is a problem about asynchronism process.If I run the method by
BeginInvoke() and how can I know when the method is finish? And maybe I can
say when I can use EndInvoke()?
Nov 16 '05 #1
2 8218
Jet Leung <xi**@163.net > wrote:
There is a problem about asynchronism process.If I run the method by
BeginInvoke() and how can I know when the method is finish?
You can specify a callback delegate which is executed after the method
has finished.
And maybe I can say when I can use EndInvoke()?


You can use EndInvoke at any time, but it will block until the delegate
has finished executing.

See http://www.pobox.com/~skeet/csharp/m...ing.html#async
for more information.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
BeginInvoke executes a delegate asynchronously on the thread that the
control's underlying handle was created on, you can then query the
(IAysncResult) interface returned by the method to see if the asynchronous
call has completed, when the asynchronous operation has completed you then
use EndInvoke to retrieve the result of the asynchronous operation.

Hope this helps

Ollie

"Jet Leung" <xi**@163.net > wrote in message
news:eZ******** *****@tk2msftng p13.phx.gbl...
Hi All,
There is a problem about asynchronism process.If I run the method by
BeginInvoke() and how can I know when the method is finish? And maybe I can say when I can use EndInvoke()?

Nov 16 '05 #3

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

Similar topics

2
15525
by: Nick | last post by:
Hi all, Are the two snippets below equivelent, since they both only continue once the ShowForm method returns??? 1. delShowForm del = new delShowForm(ShowForm); //show form shows a form IAsyncResult asyncResult = this.BeginInvoke(del); asyncResult.AsyncWaitHandle.WaitOne(); this.EndInvoke(asyncResult);
4
2876
by: Max | last post by:
Hi! In <MPG.1b660df23c2f8b6498af23@msnews.microsoft.com> Jon Skeet said that he _believes_ that for UI calls the WinForms team has _basically_ guaranteed that EndInvoke is not required after BeginInvoke. In my applications I only want to update some controls from other threads most of the time and absolutly don't care about the result (actually there is no result when I only want textBox.Text = "text").
4
2375
by: Jon | last post by:
Why are out parmeters included in an BeginInvoke? They seem to do nothing? TestProgam: using System; namespace TempConsole { class App { public delegate void MyDelegate( out byte b, out string s );
7
4531
by: nick_tucker | last post by:
Is The following Code valid it is like a mini thread pool(a friend at work wrote it)? I have cut down the code a bit but kept the essential parts. The main part that I am would like explainedis when the async callback gets called and the the line m_WaitCallback.EndInvoke(AsyncResult); How does it know which method has ended. i.e. does the AsyncResult identify it?? Is it accepable to have one member variable used for all of the...
6
15162
by: Valerie Hough | last post by:
I'm not entirely sure what the difference is between these two approaches. In order to avoid reentrant code, I was using Control.BeginInvoke in my UI to cause an asynchronous activity to be done on the UI's message loop. I began to get System.ExecutionEngineException errors so (on the theory of do something different if what you're doing isn't working) I switched to using delegate.BeginInvoke with the appropriate EndInvoke and the problem...
2
1556
by: =?Utf-8?B?Q2hhcmxpZQ==?= | last post by:
Hi guys, I'm using delegates to execute a group of methods using the BeginInvoke, that works fine; I'm waiting for the asynch thread to return the response using the EndInvoke, that works fine also. The point is, I didn't find the way to pass a null value to the BeginInvoke method for the AsyncCallback and object argument. I don't want to have unused code on my source code, but I didn't find the way to avoid it. Any thoughts? return...
5
6594
by: FP | last post by:
Hi, i'm currently developing a class to communicate with a serial device,using the SerialPort component. Basically,the main application will interact with this class through its method "Call",the class itself will handle all the details of a call (AT commands included). My problem is that i dont want the application to hang while i'm interacting with the modem,so i have started to learn about threading. Many people have suggested me to...
1
2137
by: Curious | last post by:
I have the following code: if (this.InvokeRequired) { IAsyncResult result = this.BeginInvoke(new EventHandler(this.UpdateButtons), new object { this, EventArgs.Empty }); while ((!result.IsCompleted) && (result.AsyncWaitHandle.WaitOne(100, false)))
9
3991
by: Bob Altman | last post by:
I'm trying to call a function on a background thread in a C++/CLI (VS 2005) application compiled with /clr. I store a delegate reference in a module-level gcroot. When I call BeginInvoke on the delegate I get a RemotingException. The inner exception says "Pointer types cannot be passed in a remote call". A code example that demonstrates the problem appears below. Am I even wiring up the delegate/BeginInvoke/EndInvoke stuff correctly? ...
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
10389
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10402
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
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
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3867
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.