Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strike>It will get called unless your executable is forcibly closed (via task manager or <code>taskkill</code> from the command line) or the program crashes.</strike></p> <p>EDIT: I did some experimentation and found the following:</p> <ul> <li>If you set your reference to the form to null, the form remains visible, and when the form is closed, the event gets raised.</li> <li>If your form is a child form and the main form gets closed, the child form closes WITHOUT the event being raised.</li> <li>If you call the form's <code>Hide()</code> method, the event does NOT get raised. Subsequently closing the main form, as mentioned above, will not cause the event to get raised.</li> <li>Overriding <code>OnClosed()</code> will not help because it's still not called if the main form is closed.</li> <li>Calling the form's <code>Dispose()</code> method (which is what the GC would eventually do if nothings pointing at it) will also not cause the event to get raised.</li> </ul> <p>It looks like there really isn't a way to GUARANTEE the code will get called from within the form. You can put the code after the <code>Application.Run();</code> in your <code>Main()</code> and it will get called there. There's also an event for <code>Application.ApplicationExit</code> that would get called unless you have exceptional circumstances (forcibly closed or crash).</p> <p>You can register a handler for the <code>Application.ApplicationExit</code> event in your form, but be aware that by this time, your object has already been disposed, so you can't do anything with it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload