This is not a boundary between C# and C++/CLI, there is only a boundary between C++ and C++/CLI.
There are no "function pointers" (which is low-level and not really robust concept in view of OOP) in .NET, there are only delegates. A delegate instance is a structure with includes the collection of entry points of some code of a methods, each with the value of the class/structure instance implementing the method (same as "this" pointers passes in every instance (non-static) method; this collection is called invocation list and can be traversed explicitly via invocation of the delegate instance of explicitly through
System.Delegate.GetInvocationList
. Only for a static method "this" is not used. Static and instance methods can mix up in any invocation list.
Difference between C# and C++/CLI languages is not essential here:
C++/CLI:
aTimer->Elapsed += gcnew ElapsedEventHandler(TimerFire);
void TimerFire(Object ^sender, ElapsedEventArgs ^e) { }
C#:
void TimerFire(Object sender, ElapsedEventArgs e) { }
aTimer->Elapsed += new TimerFire;
aTimer2->Elapsed += new ElapsedEventHandler(TimerFire);
aTimer3->Elapsed += delegate(object sender, ElapsedEventArgs eventArgs) {
};
aTimer4->Elapsed += (sender, eventArgs) => {
};
You can use these declarations in any combination: write implementation on C# and add to the invocation list in C++/CLI or the other way around.
A final notice: avoid using timers by all means. Use threads instead!
—SA