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.

DynamicInvoke and BeginInvoke

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ricardo - 03 Aug 2005 18:10 GMT
Hi. I'd like to know more about the diference between the DynamicInvoke and
the BeginInvoke methods. It seems that BeginInvoke uses the DynamicInvoke
method internally, but I'm not sure about this. So what's the difference in
terms of performance? What happens if I call BeginInvoke and do not call
EndInvoke? Is there a situation when one is better than the other?

Thanks
S. Senthil Kumar - 03 Aug 2005 19:35 GMT
BeginInvoke is used to execute the delegate on a threadpool thread.
DynamicInvoke, IIRC, is just a convenient way of invoking a delegate
without knowings its type. You could do, for example,
Delegate d = new SomeDelegate(SomeMethod);
d.DynamicInvoke(new object[] {param1, param2})

instead of
SomeDelegate d = new SomeDelegate(SomeMethod);
d(param1, param2);

DynamicInvoke is useful when you don't know the exact signatures of the
methods in advance.

Every call to BeginInvoke must be accompanied by EndInvoke. You'll leak
resources if you don't. What's more, if the method threw an exception,
EndInvoke will cause it to be rethrown, so if you don't call EndInvoke,
you'll never know if the method executed successfully.

Regards
Senthil
Ricardo - 03 Aug 2005 19:50 GMT
Your answer was very clear. Thanks.

Ricardo

> BeginInvoke is used to execute the delegate on a threadpool thread.
> DynamicInvoke, IIRC, is just a convenient way of invoking a delegate
[quoted text clipped - 16 lines]
> Regards
> Senthil
Ricardo - 05 Aug 2005 19:01 GMT
Only one more question: the BeginInvoke and the DynamicInvoke methods use the
ThreadPool or the DynamicInvoke executes the method on the same thread?

Ricardo
S. Senthil Kumar - 06 Aug 2005 14:25 GMT
DynamicInvoke executes the method on the same thread.

Regards
Senthil

Rate this thread:







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.