473,322 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Why the function need to run by the delegate?

Hi:
I had asked how to use delegate in the programming. And now actually I want
to know why and when the function need to run by the delegate?
Nov 16 '05 #1
2 1157
hello,

Hope by now you knew how to use delegates, now question is why and when? Its more relevant to library developers, think of a scenario where you want that implementation of your function ABC() could be provided by any developer consuming your library but you don't want to impose name restrictions on it. Delegates provide an elegant method to register signature of to be implemented method and calling these methods without having type information from called assembly beforehand.
Nov 16 '05 #2
You already use delegates all the time when you deal with events in .NET
classes. If you had a bankAccount class and wanted to implement an
AccountOverdrawn event for instance whenever X happens, you'd raise an event
in the get/set accessor and use a delegate as the event handler.
"Jet Leung" <xi**@163.net> wrote in message
news:uS**************@TK2MSFTNGP10.phx.gbl...
Hi:
I had asked how to use delegate in the programming. And now actually I want to know why and when the function need to run by the delegate?

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ian Richardson | last post by:
I'm writing some code which does one thing when onreadystatechange occurs, e.g. handle.onreadystatechange = function() { blah(handle,other_params) }; ....but sometimes I need to add another,...
10
by: ChrisB | last post by:
Coming from a C/C++ background, how would I pass a function pointer to a function? I want to write a function that handles certain thread spawning. Here's what I'm trying to invision: function(...
0
by: Haxan | last post by:
Hi, I have an unmanaged application that converts a function pointer to a delegate and then pass this as a parameter(delegate) to a managed function which then invokes it. Currently Im able to...
12
by: Haxan | last post by:
Hi, I have my main application class(unmanaged) that has a none static member function that I need to pass as a delegate to managed C# method. In one of the methods of this class(unmamanged),...
5
by: Filippo Bettinaglio | last post by:
I have a DLL written in C++ (unmanaged), which I want to inteface with. I created a standard window form program with VC++ 2005, all fine I have imported an .h file the .lib file and all works. ...
6
by: Bart Burkhardt | last post by:
Hi, I could use some help in setting a C# callback function that an external unmanaged dll will call on a event. Using a delegate and use the external callback set function doesn't work. The...
2
by: esource | last post by:
Hi all, I'm trying to use threading model in my web service but addressof does not work with functions I'm using VS 2005 my code: Public Function Start() as Boolean Dim MyThread As New...
5
by: hurricane_number_one | last post by:
I'm trying to have a class, which uses threads be able to raise events to the form that created it. I've seen solutions around the net for this, but I didn't really like their implementation. ...
2
by: Franck | last post by:
I am looking for a way to pass a function as parameter, NOT A DELEGATE. what i am trying to do is a worker process as for example of what i want to do : public static void...
10
by: vcquestions | last post by:
Hi. Is there way to have a function pointer to a delegate in c++/cli that would allow me to pass delegates with the same signatures as parameters to a method? I'm working with managed code. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.