It it possible to retrive who is subscribing to a event in C#?
example
class MyClass
{
public string Name { get; set; }
}
class Syncronizer
{
public delegate void SynchronizatonEventHandler(MyClass myClass);
public event SynchronizatonEventHandler OnSyncFinished;
}
If i have something like that is it possible for me to see/use the myClass.Name string and use it for logging when the event is subscribed to?
What i want to accomplish is that i want to log every subscribe and unsubscribe from my Syncronizer class.
Here’s a working example:
Note that you can not log myClass.Name, since that doesn’t exist in the add and remove procedures. I have it logging (to Console.WriteLine) the class and method that subscribed to the event, which is, I think, what you were after.