Huahh! Don't do that (No offense Mattias;-) - I strongly recommend the
use of interfaces for COM callbacks. That's quite easy to do with .NET's
[ComVisible] attribute and friends.

Passing plain function pointers looks like a good idea, but I can tell
you: It isn't! I've been the one to debug such "creative solutions" for
the last years and I can tell you that is absolutely no fun. With
functions pointers you e.g. bypass apartment switches quite easily and
if this happens it will drive you nuts. And this is only one bad thing
that might happen...

My regards
        Axel

-----Original Message-----
From: Mattias Sjögren [mailto:[EMAIL PROTECTED]]
Sent: Dienstag, 23. April 2002 21:34
To: [EMAIL PROTECTED]
Subject: Re: [DOTNET] Callback? Possibble from C#?


Tomas,

Try something like this

typedef int (__stdcall *TheCallbackType) (int);

DECLARE_INTERFACE_(umIDataSink, IUnknown)
{
         STDMETHOD(SetCallback) (THIS_ TheCallbackType Callback) PURE;
};

and on the managed side

delegate int TheCallBackType(int i);


But why are you using a function pointer rather than an interface for 
callbacks?


Mattias

===
Mattias Sjögren
[EMAIL PROTECTED]

You can read messages from the DOTNET archive, unsubscribe from DOTNET,
or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to