Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

delegate

Posted on 2009-04-11
2
Medium Priority
?
272 Views
Last Modified: 2012-05-06
When it is right to use Delegate in Vb.net? I am a bit confused.
0
Comment
Question by:VBdotnet2005
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 5

Expert Comment

by:brandonvmoore
ID: 24124470
Delegates are generally used when there is communication going on between your code and some other external application or code/library.  A delegate is the same thing as a callback function.

Delegates are one of those things that are sometimes difficult to understand until you are actually doing something that requires one.  If you have a specific problem that you think might require one, why don't you explain it and I'll see if I can demystify it for you.
0
 
LVL 5

Accepted Solution

by:
brandonvmoore earned 500 total points
ID: 24124478
By the way, you use delegates all the time without knowing it.  All the events that you write code for (ie. a mouse click) are delegates.  But VB just takes care of the details of setting them up for you as delegates to the operating system.  Another way of thinking of delegates are as pointers to functions.

In other words, I don't actually give the operating system the actual code that I want it to run when a mouse gets clicked.  I just tell the operating where that code is by giving it a pointer (or delegate).  You really won't need to be giving any delegates to the operating system as these are built in to the language already.  But let's say that you have an application that has to get data from another application to display.  A excellent real life example of this would be a webpage.  Because the javascript on a webpage has to make a call to an asp page (written in vb) on a server to let it know what data it needs.  The webpage has no control over how long it's going to take for the server to respond and needs to keep functioning in the meantime.  So it makes a callback function to be called when the response from the server comes back.

Hope that helps.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question