When use a delegate?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Cirene

    #1

    When use a delegate?

    When would you choose to use a delegate rather than calling a function
    directly? What's the advantages? Thanks...


  • Cowboy \(Gregory A. Beamer\)

    #2
    Re: When use a delegate?

    One prime example is events.

    Another is when you have to run more than one "function" when a specific
    action happens.

    Another is when you have a library that has to make a callback to the
    calling application, but you do not know what the event name is at the time
    you create the library.

    --
    Gregory A. Beamer
    MVP, MCP: +I, SE, SD, DBA

    Subscribe to my blog


    or just read it:


    *************** *************** *************** ****
    | Think outside the box!
    |
    *************** *************** *************** ****
    "Cirene" <cirene@nowhere .comwrote in message
    news:eeT9P31mIH A.4208@TK2MSFTN GP02.phx.gbl...
    When would you choose to use a delegate rather than calling a function
    directly? What's the advantages? Thanks...
    >

    Comment

    • Scott M.

      #3
      Re: When use a delegate?

      Sometimes you don't know what function you're going to want to call, only
      its signature. Delegates allow you that flexibility.


      "Cirene" <cirene@nowhere .comwrote in message
      news:eeT9P31mIH A.4208@TK2MSFTN GP02.phx.gbl...
      When would you choose to use a delegate rather than calling a function
      directly? What's the advantages? Thanks...
      >

      Comment

      • Cirene

        #4
        Re: When use a delegate?

        Thanks Cowboy, Scott, Jordan and everyone else. You guys are awesome...

        "Cowboy (Gregory A. Beamer)" <NoSpamMgbworld @comcast.netNoS pamMwrote in
        message news:u95hmA2mIH A.2304@TK2MSFTN GP05.phx.gbl...
        One prime example is events.
        >
        Another is when you have to run more than one "function" when a specific
        action happens.
        >
        Another is when you have a library that has to make a callback to the
        calling application, but you do not know what the event name is at the
        time you create the library.
        >
        --
        Gregory A. Beamer
        MVP, MCP: +I, SE, SD, DBA
        >
        Subscribe to my blog

        >
        or just read it:

        >
        *************** *************** *************** ****
        | Think outside the box! |
        *************** *************** *************** ****
        "Cirene" <cirene@nowhere .comwrote in message
        news:eeT9P31mIH A.4208@TK2MSFTN GP02.phx.gbl...
        >When would you choose to use a delegate rather than calling a function
        >directly? What's the advantages? Thanks...
        >>
        >
        >

        Comment

        Working...