I have a system comprising a C# UI, a C++/CLI mixed mode interop wrapper, and some native c++ projects.
What I need to do is set up a system such that the native c++ code can send a log message, and the UI can report it.
I set up a native IObservable using this as a template, but then the C# code can't be an observer. My thought was to set up another observer pattern in C++/CLI, which observes the native observer, and to let the C# implement that. I used this as a template but I'm struggling to convert this into valid C++/CLI.
ref class Observable
{
public:
Observable(void);
virtual ~Observable(void);
event System::EventHandler^ SomethingHappened;
void DoSomething() {
System::EventHandler^ handler = SomethingHappened;
//if (handler != nullptr)
//{
handler(this, System::EventArgs::Empty);
//}//null check not permitted in C++/CLI
};
Gives the error: C3918: requires SomethingHappened to be a data member. This is the MSDN page - but I can't identify what I'm doing wrong.
Any suggestions?
Thanks, Melanie