Click here to Skip to main content
15,895,192 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Happy new year

// Occurs when myEvent triggered
public delegate void MyEventHandler(object sender, MyEventArg eventArgs);

// Provides data for myEvent
public class MyEventArg : EventArg
{}
// C# interface
public interface IMyInterface
{
event MyEventHander myEvent;
}

///////////////////////////////
// C++/CLI

public ref MyClass: public IMyInterface
{
public:
   virtual event MyEventHandler^ myEvent;
   // need to implement add,remove,raise, fire???

}


I need to implement this interface in both C++/CL and C#
any one have idea about this

I have tried but my solutions are not working

Thanks in Advance
Radhakrishnan G.
Posted
Updated 31-Dec-10 2:06am
v3
Comments
Espen Harlinn 31-Dec-10 8:40am    
Well, if you can't translate it into c++, I'm not sure anything I could do would help you.
This might help: http://stackoverflow.com/questions/462805/proper-way-of-raising-events-from-c-cli
Giving a vote of 1 reduces my rating on CodeProject - you do know that don't you?

1 solution

in c# it will look like

C#
public event MyEventHander myEvent;

private void FireMyEvent( MyEventArg myEventArg  )
{
  if(myEvent != null)
  {
    myEvent(this,myEventArg);
  }
}


Regards
Espen Harlinn
 
Share this answer
 
v2
Comments
Radhakrishnan G. 31-Dec-10 8:18am    
Thanks for your quick reply,
Radhakrishnan G. 31-Dec-10 8:22am    
I need C++/CLI implementation, I am doing some unmanaged stuff with this, so I am making this question unanswered
Espen Harlinn 31-Dec-10 8:37am    
Well, if you can't translate it into c++, I'm not sure anything I could do would help you.
This might help: http://stackoverflow.com/questions/462805/proper-way-of-raising-events-from-c-cli
Giving a vote of 1 reduces my rating on CodeProject - you do know that don't you?
Manfred Rudolf Bihy 31-Dec-10 9:27am    
@Radhakrishnan: In your question you specifically asked also for a C# solution. So why would you downvote somebody who helped you in your quest for knowledge?
You are not showing good manners! X|
Manfred Rudolf Bihy 31-Dec-10 9:30am    
@Espen: I've decided to compensate! Take my 5!
I also wish you all a blessed, successful and mostly Happy New Year!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900