views:

37

answers:

1

I have a form that is closed unexpectedly immediately after showing it. I hooked all the usual events that occur when a form is closed, but none of it is fired (including Closed, Closing, FormClosed, FormClosing, VisibleChanged, Disposed). How can that happen? What can cause a form to disappear without any of the mentioned events firing?

+1  A: 

Sounds like a threading issue. My guess is that the form is created on a separate thread, and when the thread dies, the form disappears without a trace.

(That exact behaviour was my introduction to writing thread safe code once upon a time.)

Fredrik Mörk
Must be the fasted accepted answer ever. You are so right. The creating thread dies shortly after creating the form...
EricSchaefer