Search code examples
.netwinformswindow-handles

Is there an event when the window handle is destroyed


Since the destruction of a window handle disables the invoke mechanism, I do want to unsubscribe to an background-worker that notifies me.

So is there an event that is fired shortly before the window handle of a windows form is closed.

( I have seen this Is there a variant of Control.BeginInvoke which works before/after the handle is destroyed? but I do not like it and if possible want to avoid it... )

TIA

Mario


Solution

  • You can use the HandleDestroyed event (or override the OnHandleDestroyed method).