Solved

delegate

Posted on 2009-04-11
2
260 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 125 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.NET - Refactor Class per SOLID principles 2 43
ASP.NET Complete Life Cycle for all the controls 2 45
SSIS - Using VB.NET to parse XML file 11 42
Subtract dates in vb.net 6 35
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

751 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