Tech Off Post

Single Post Permalink

View Thread: Please, I'm panicing and only have 2 days left.
  • User profile image

    Rossj wrote:
    qwert231 wrote: It also crashes if I let the software sit for a while, even without the controls.

    Is the class containing the delegate going out of scope and getting GC'ed ?

    From MSDN

    Note   When you use a delegate inside a call, the common language runtime protects the delegate from being garbage collected for the duration of that call. However, if the unmanaged function stores the delegate to use after the call completes, you must manually prevent garbage collection until the unmanaged function finishes with the delegate.

    This is likely the issue,The easiest way is to  mark your managed function as static, so it does not get moved around or GC'ed.