我有以下C#代码,它使用通用的EventHandler
委托:
public class EventSource
{
public event EventHandler<MyEventArgs> SomethingHappened;
}
我尝试从C ++ \ CLI代码订阅此事件:
public ref class EventSink
{
public:
void Handler(Object^ sender, MyEventArgs^ args)
{
DoSomthing(args);
}
};
class Manager
{
private:
gcroot<EventSource^> _eventSource;
gcroot<EventSink^> _eventSink;
public:
Manager()
{
_eventSource = gcnew EventSource();
_eventSink = gcnew EventSink();
_eventSource->SomethingHappened += // What do I put here?
}
}
如何实例化EventHandler
委托以传递给_eventSource->SomethingHappened.Add
属性?