Design and Implementation of Distributed Applications - 2021/2022

1st Year, 1st Semester

MEIC - Campus Alameda
MEIC - Campus Tagus Park
METI - Campus Tagus Park

Lab. 2 - Additional C# Topics

Support material:

A - Delegates

Study and run exercise-1.cs. Modify the example as you see fit in order to answer the following questions:
  1. Find the place in the code where the addition, removal and assignment of methods to the delegates is made.
  2. In which order are the methods added to the delegates invoked?
  3. What happens if you assign null to a delegate before invoking it?
  4. Is it possible to assign static methods to delegates?
  5. What happens to the registered methods in a delegate if a new method is assigned? Are they invoked?
  6. Check if it's possible to pass a delegate as a method paramenter and call it in the method.

B - Events

Study the code in exercise-2.cs which simulates a connection between a list and another class listening to changes on the list.
a) Implement the code needed to ensure that the subscriber becomes a aware of when a product is added and when a different operation happened.
b) Check what happens if you try to trigger the event outside of the class where it is declared.

C - Threads

Implement a thread pool so that:
Base your solution on the code in exercise-3.cs.