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 / Windows Forms / WinForm General / July 2006

Tip: Looking for answers? Try searching our database.

How to make asynchronous call ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Laurent - 14 Jul 2006 16:50 GMT
Hi all,

First, I use C# with the .NET Framework 2.0.

I would like in the method OnButtonClick, call the method A.DoSomething but
in a way that executes after
OnButtonClick has finished its execution.
I am looking for something like a PostMessage in Win32 in fact.
How can I do that in C# ?

Class A
{
   // may be inheriting from Form too
   void DoSomething() { }
}

Class B : Form
{
   void OnButtonClick() // for example
   {
       // call A.DoSomething but do not execute yet

       return;
       // now it is the time that DoSomething must execute
   }
}

Thank,
Laurent
Joris Zwaenepoel - 19 Jul 2006 10:15 GMT
I'm more a VB.NET programmer, so I cannot give youC# source code, but you
could gave a look at delegates and the "BeginInvoke" method that you can use
to start a method on a background thread and continuing your main thread in
the meantime.  

If you want it to only start executing when you calling method has finished,
then you probably need to put the method call to BeginInvoke as the last
statement before the "return" statement in your example.

Hope this helps,

Joris

> Hi all,
>
[quoted text clipped - 25 lines]
> Thank,
> Laurent

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.