المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : C# - listen to add/remove function from event



C# Programming
12-31-2009, 07:23 AM
how can i know when a function is been added/removed from my Event?

I want to do some connection when a COM is add a function to my event.

public delegate void DoItDelegate(int i);
....
....
{
DoItDelegate MyFunction;

MyFunction += new DoItDelegate(DoItFunction);

}

public void DoItFunction(int i)
{
//Do Domthing
}


When the command : "MyFunction += new DoItDelegate(DoItFunction); " is been execute i want to do something in another function.

What can i do if i want to know when this "MyFunction += new DoItDelegate(DoItFunction);" is execute and register it to Datatable?

(The command "MyFunction += new DoItDelegate(DoItFunction);" is in the COM code and not in my code so i can't control it.)