Click to See Complete Forum and Search --> : One Line C# -> C++/CLI Conversion Help


2MuchRiceMakesMeSick
December 12th, 2006, 07:26 AM
Can someone help me convert this code

// this compiles with a C# compiler and works fine
Ping pingSender = new Ping();
pingSender.PingCompleted += new PingCompletedEventHandler(PingCompletedCallback);





// C++/CLI code that does not compile
Ping ^ pingSender = gcnew Ping();
pingSender->PingCompleted += gcnew PingCompletedEventHandler (PingCompletedCallback);


Error 1 error C3867: 'PingTest::Form1::PingCompletedCallback': function call missing argument list; use '&PingTest::Form1::PingCompletedCallback' to create a pointer to member


and


Error 2 error C3350: 'System::Net::NetworkInformation::PingCompletedEventHandler' : a delegate constructor expects 2 argument(s)




thanks in advance for the help

wildfrog
December 12th, 2006, 07:31 AM
Something like:

Form1^ yourForm = //...

Ping^ pingSender = gcnew Ping();
pingSender->PingCompleted +=
gcnew PingCompletedEventHandler(yourForm, &Form1::PingCompletedCallback);

- petter

2MuchRiceMakesMeSick
December 12th, 2006, 07:49 AM
thanks again. I tried to give you some more rep but it said

You must spread some Reputation around before giving it to wildfrog again.

wildfrog
December 12th, 2006, 07:54 AM
thanks again. You're welcome :wave:

- petter