You might want to try unhooking hte event object before exiting. I have a couple of apps where I do this and I don't have any problems even without that. But then I don't think my code fires on additional threads. I haven't looked closely at it since it just works...
+++ Rick ---
>Rick,
>
>Don't know if you are still reading these or not, but here goes:
>
>I have followed your web example to a 'T', and have noted a few things. Foxpro is responding to the .Net event just fine from what I can see. I can see another thread being created and removed upon exit of the .net form. However, I am still getting the c000005 error when exiting the small foxpro app in both VFP7 and VFP9. Of course everything runs just as expected inside the foxpro IDE. However, as soon as I get outside the IDE and the program runs the eventhandler class, the foxpro exe will error on exit. Here's the fox code for the eventhandler:
>
>oEvents = NEWOBJECT("myclass")
>zz = EVENTHANDLER(frmShell, oEvents)
>RETURN
>
>
>DEFINE CLASS myclass AS session OLEPUBLIC
>
> IMPLEMENTS IJEEvents IN "c:\documents and settings\thompssj\my documents\visual studio projects\testfoxclass2\bin\testfoxclass2.tlb"
>
> PROCEDURE IJEEvents_ShellClosed() AS VOID
> * add user code here
> ENDPROC
>
> PROCEDURE IJEEvents_ButtonClicked() AS VOID
> MESSAGEBOX(".net form button clicked")
> ENDPROC
>
>ENDDEFINE
>
>This is pretty much standard example code right from Help. Again it works fine, the event is triggered, but exiting the foxpro exe in windows causes an error. Tried it on a couple of different machines even.