Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Multicast Delegation

Multicast Delegation

Scheduled Pinned Locked Moved C#
csharpquestionlearning
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    abalfazl
    wrote on last edited by
    #1

    Hello I read this from Professional C#,Wrox: "However, it is possible for a delegate to wrap more than one method. Such a delegate is known as a multicast delegate. If a multicast delegate is called, it will successively call each method in order." It is also said in that book: "If you are using multicast delegates, you should be aware that the order in which methods chained to the same delegate will be called is formally undefined. You should, therefore, avoid writing code that relies on such methods being called in any particular order. " Can methods in delegation run in special order?

    J E 2 Replies Last reply
    0
    • A abalfazl

      Hello I read this from Professional C#,Wrox: "However, it is possible for a delegate to wrap more than one method. Such a delegate is known as a multicast delegate. If a multicast delegate is called, it will successively call each method in order." It is also said in that book: "If you are using multicast delegates, you should be aware that the order in which methods chained to the same delegate will be called is formally undefined. You should, therefore, avoid writing code that relies on such methods being called in any particular order. " Can methods in delegation run in special order?

      J Offline
      J Offline
      joon vh
      wrote on last edited by
      #2

      I would suspect them to run in the order they are populated. They are usually added by +=, so they must be in some sort of collection, and every list or collection has a basic order. He says you shouldn't rely on it, and I can understand why as it is probably not very reliable. I'll try to look into it soon.


      Visual Studio can't evaluate this, can you? public object moo { __get { return moo; } __set { moo = value; } }

      1 Reply Last reply
      0
      • A abalfazl

        Hello I read this from Professional C#,Wrox: "However, it is possible for a delegate to wrap more than one method. Such a delegate is known as a multicast delegate. If a multicast delegate is called, it will successively call each method in order." It is also said in that book: "If you are using multicast delegates, you should be aware that the order in which methods chained to the same delegate will be called is formally undefined. You should, therefore, avoid writing code that relies on such methods being called in any particular order. " Can methods in delegation run in special order?

        E Offline
        E Offline
        Ennis Ray Lynch Jr
        wrote on last edited by
        #3

        Use GetInvocationList() from your delegate. This will give you the full list of listeners. You can then roll your own call order from the mechanism that fires them, ie the OnX method.


        File Not Found

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups