GIDForums  

Go Back   GIDForums > Computer Programming Forums > .NET Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 26-Feb-2009, 17:35
BobLewiston BobLewiston is offline
Junior Member
 
Join Date: Nov 2008
Posts: 53
BobLewiston is on a distinguished road

Why use delegates?


Why use delegates?

I understand HOW to use delegates, but in what situations would you actually use them? The examples I see in the literature are all in situations where the code could just be written without ever using them.
  #2  
Old 27-Feb-2009, 07:57
fakepoo fakepoo is offline
Regular Member
 
Join Date: Oct 2007
Posts: 969
fakepoo is a jewel in the roughfakepoo is a jewel in the roughfakepoo is a jewel in the rough

Re: Why use delegates?


You need them when multi-threading. If a worker thread needs to update the GUI, it needs to do so with a delegate. See Invoke() for details.
  #3  
Old 06-Apr-2009, 06:14
erniegerdie erniegerdie is offline
Awaiting Email Confirmation
 
Join Date: Feb 2004
Location: England
Posts: 93
erniegerdie has a spectacular aura abouterniegerdie has a spectacular aura about

Re: Why use delegates?


They also allows for late-bound functions/methods calls to be performed at runtime rather than being bound at compile time.This allows for more flexible and dynamic coding.
  #4  
Old 26-Jan-2012, 23:58
simonjhons16 simonjhons16 is offline
Account Disabled
 
Join Date: Jan 2012
Location: India
Posts: 1
simonjhons16 is on a distinguished road

Re: Why use delegates?


Hello Friends........

A Delegate is a type/ a functional pointer/ have a reference of amethod. Once a delegate is assigned a method, it behaves exactly like that method. You can have multiple method in a delegate that we call it as multicast delegate.

you can assign an event also in a delegate. if you want to switch the event / a method dynamically at runtime you can achieve this using delegates.
  #5  
Old 04-Jun-2012, 22:57
Maximlis Maximlis is offline
New Member
 
Join Date: May 2012
Location: Pune
Posts: 9
Maximlis is an unknown quantity at this point

Re: Why use delegates?


A delegate is a type that acts as a reference to a method. Once a delegate is assigned a method, it behaves just like that method. The delegate method can be used like any other normal method, with parameters and a return value.
  #6  
Old 29-Aug-2012, 04:45
preetisoft2 preetisoft2 is offline
Account Disabled
 
Join Date: Aug 2012
Posts: 19
preetisoft2 has a little shameless behaviour in the past

Re: Why use delegates?


Delegates are used in multithreading and cross-thread operations.
  #7  
Old 03-May-2013, 01:23
johnsmithh134 johnsmithh134 is offline
New Member
 
Join Date: May 2013
Posts: 8
johnsmithh134 is an unknown quantity at this point

Re: Why use delegates?


Delegate is a type which hold the reference of a method or delegate points the method. Delegate has same structure as a method which is hold by that delegate. Declaration of delegate like:
[attributes] [modifiers] delegate result-type identifier ([formal-parameters]);
  #8  
Old 27-Oct-2015, 01:19
lindseynicole lindseynicole is offline
New Member
 
Join Date: Oct 2015
Posts: 13
lindseynicole has a little shameless behaviour in the past

Re: Why use delegates?


Delegates is used as pointer function.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Delegates and references to objects BobLewiston .NET Forum 0 02-Feb-2009 20:18
Delegates VC++ 2005 Question bhaskar27in .NET Forum 2 15-Sep-2006 06:13

Network Sites: GIDNetwork · GIDApp · GIDBlog · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 23:04.


vBulletin, Copyright © 2000 - 2017, Jelsoft Enterprises Ltd.