Multicast Delegation
-
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?
-
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?
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; } }
-
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?
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