Thanks Daniel, to make sure here's the code snippet:
public class WrapCDLL
{
public delegate void CallBack(IntPtr data);
static WrapCDLL()
....}
public class MyApp
{
public static WrapCDLL.CallBack myNotifyListenerDelegate;
public static void NotifyListener(IntPtr lpUnmanagedData)
{...}
public int Run() //the main loop entered after instantiating
MyApp
{myNotifyListenerDelegate = new
WrapCDLL.CallBack(NotifyListener);
......}
....}
"Daniel Moth" wrote:
> Declare the delegate outside the function at the type level (assuming the
> instance of the type is not eligible for GC, neither will the delegate). If
> you are still in doubt, post your snippet.
>
> Cheers
> Daniel
> --
> http://www.danielmoth.com/Blog/
>
> "tb2000" <(E-Mail Removed)> wrote in message
> news:C84CC5B9-F590-41E2-86FA-(E-Mail Removed)...
> > When using a delegate for callback from an unmanaged dll: do I have to fix
> > (
> > (how do i?) that delegate somehow so that is will not be 'moved' on
> > garbage
> > collection or voided totaly after the procedure is vacated so the
> > unmanaged
> > pointer will loose it's relevance?
> > Thanks!
> > tb
> >
> >
> >
>
>
>