PrepAway - Latest Free Exam Questions & Answers

9 Comments on “For each of the following statements, select Yes if the statement is true…

    1. PaulC says:

      Yes Yes No is correct.

      in multithread environment it might be displayed differently… but in a single thread it always iterate the collection of subscribers in order they are subscribed. there is no parallel iteration involved.




      0



      0
  1. Deav says:

    Yes, Yes, No.

    Events are multicast delegates and that one has a linked list to store the delegates in. The order of execution is always the same as they are inserted.

    Quote:
    “An event is nothing but an encapsulated multicast delegate. It can store references to more than one method or event handler. The methods will be executed in the same order as they are added to the event. “




    1



    0
    1. kasp says:

      Still not 100% sure but I believe you are write as it is not a multi thread environment:

      The invocation list of a delegate is an ordered set of delegates in which each element of the list invokes exactly one of the methods invoked by the delegate. An invocation list can contain duplicate methods. During an invocation, a delegate invokes methods in the order in which they appear in the invocation list. A delegate attempts to invoke every method in its invocation list; duplicates are invoked once for each time they appear in the invocation list. Delegates are immutable; once created, the invocation list of a delegate does not change.
      A delegate is either multicast (combinable) or singlecast (noncombinable). Multicast or combinable delegates invoke one or more methods, and can be used in combining operations. Singlecast or noncombinable delegates invoke exactly one method and cannot be used in combining operations. The invocation list of a singlecast delegate A contains a single element: a reference to A.

      https://msdn.microsoft.com/fi-FI/library/windows/apps/system.delegate(v=vs.71)




      0



      0
  2. rao says:

    YES YES NO.
    TESTED.

    public class Alert
    {
    public EventHandler SendMessage;
    public void Execute()
    {
    SendMessage(this, new EventArgs());
    }
    }
    public class Subscriber
    {
    Alert alert = new Alert();
    public void Subscribe()
    {
    alert.SendMessage += (sender, e) => { Console.WriteLine(“First”); };
    alert.SendMessage += (sender, e) => { Console.WriteLine(“Second”); };
    alert.SendMessage += (sender, e) => { Console.WriteLine(“Third”); };
    alert.SendMessage += (sender, e) => { Console.WriteLine(“Third”); };
    }
    public void Execute()
    {
    alert.Execute();
    }
    static void Main(string[] args)
    {
    Subscriber subscriber = new Subscriber();
    subscriber.Subscribe();
    subscriber.Execute();
    Console.ReadKey();
    }
    }




    0



    0

Leave a Reply