Delegate question

  • Thread starter Thread starter M.Posseth
  • Start date Start date
M

M.Posseth

Hi ,,,

Could someone explain to me why and when i would use a delegate , instead of
just calling the method directly ??

I do understand how they work however i do not see anny usage for them
sofar or am i missing something ?





M. Posseth
 
Hi,

Delegates are good for running a procedure asynchronously (in
background). You also need to use them for call back functions with a win32
api.

http://msdn.microsoft.com/library/d...imeremotingmessagingasyncresultclasstopic.asp

http://msdn.microsoft.com/library/d.../cpguide/html/cpconUsingCallbackFunctions.asp


Ken
---------------

Hi ,,,

Could someone explain to me why and when i would use a delegate , instead of
just calling the method directly ??

I do understand how they work however i do not see anny usage for them
sofar or am i missing something ?





M. Posseth
 
Ken ,

Thank you , these articles explained a lot

It is more clear to me now , as a old school VB programmer i thought
delegate why ?? but i know now that it is just nothing more than a
type-safe method definition.



--
Met vriendelijke groet
Kind regards,

Michel Posseth
 
I'd like to add a bit more.

Delegates allow you to declare a datatype that is actually a pointer to a
function. So what that essentially lets you do is, it lets you create a
"hook" in a class that allows other classes to latch onto that hook at
runtime and let the first class communicate with the latched on subscriber
classes.

The best part is that you can have multiple subscribers (latched on classes)
and these subscriptions can be added/removed at runtime.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top