stoping delegate from getting gc'ed

Aug 1 2007 4:38 PM
Hi, using a delegate to handle an event im getting from an api call, only problem is its being destroyed by GC and not sure how to stop this ..

private delegate void StartStopEventDelegate(short Channel, short Event);
[DllImport("c:\\mydll.dll")]
private static extern char SetCallBack_StartStop(StartStopEventDelegate myDelegate);

then use of above code which is done i

SetCallBack_StartStop(startstop);

void startstop(short channel, short event)
{
    //lotsa stuff here
}

after i force GC or wait for GC i get

A callback was made on a garbage collected delegate of type

please help



Answers (3)