I’m using a third party ActiveX control in my .NET Application. I manage to handle the callback in unmanaged C++ like this:
class MyCallback : public ICallback
{
…
void OnComplete() {…}
}
…
MyCallback *callback = new MyCallback();
someobject->SomeFunction(“just a string”, callback);
The function OnComplete is apart of the ICallback interface.
In C++ the method OnComplete will be called some seconds after SomeFunction has been called.
How do I translate that into C#?
I’ve come this far:
public class MyCallbackSC : ICallback
{
…
void OnComplete() {…}
}
…
MyCallback callback = new MyCallback();
someobject.SomeFunction(“just a string”, (object)callback);
My C# program compiles fine but when I got an exception on the codeline above that says: InvalidCastException.
Anyone got any ide how to handle callbacks in C#...?
class MyCallback : public ICallback
{
…
void OnComplete() {…}
}
…
MyCallback *callback = new MyCallback();
someobject->SomeFunction(“just a string”, callback);
The function OnComplete is apart of the ICallback interface.
In C++ the method OnComplete will be called some seconds after SomeFunction has been called.
How do I translate that into C#?
I’ve come this far:
public class MyCallbackSC : ICallback
{
…
void OnComplete() {…}
}
…
MyCallback callback = new MyCallback();
someobject.SomeFunction(“just a string”, (object)callback);
My C# program compiles fine but when I got an exception on the codeline above that says: InvalidCastException.
Anyone got any ide how to handle callbacks in C#...?