Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / August 2005

Tip: Looking for answers? Try searching our database.

A Question about Control.Invoke

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ozbear - 11 Aug 2005 23:30 GMT
I have a code sequence that goes something like this:

1. Start an asynchronous i/o with a completion callback of /cb/

Now when the i/o completes we end up in the /cb/ routine....
note that we are in a pool thread during the callback, not the
main form's thread.

2. call the Endxxxx(ar) to retrieve the results of the operation
3. form.Invoke(delegate method, params)
4. do another asynchronous i/o for more data

At step 3 we call Invoke to switch to the main form's thread and
pass it some data.  This is necessary since doing anything with
form's controls outside its main thread is not safe.

My question is what is Invoke doing under the covers?  Does it
just launch the delegate with the equivalent of a PostMessage or
PostThreadMessage and return straightaway so we can get the next
i/o started at step (4), or is step (4) not executed until the
delegate method (and any routines it calls in turn) in step (3)
completed?

I can change Invoke to BeginInvoke if that is what is required.

Regards, Oz

Signature

A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

Mehdi - 12 Aug 2005 00:03 GMT
> My question is what is Invoke doing under the covers?  Does it
> just launch the delegate with the equivalent of a PostMessage or
> PostThreadMessage and return straightaway so we can get the next
> i/o started at step (4), or is step (4) not executed until the
> delegate method (and any routines it calls in turn) in step (3)
> completed?

Invoke blocks until the method that you are invoking returns. If you want
your UI method invocation to return immediately, use BeginInvoke.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.