HwndSource.Dispose Method

Definition

Releases all managed resources that are used by the HwndSource, and raises the Disposed event.

C#
public void Dispose();

Implements

Remarks

Important

This method is not available in the Internet security zone.

Dispose initiates related cleanup work for the HWND. If Dispose is called through a thread that is different from the main UI thread, the cleanup work may be deferred until it can be posted to the main UI thread.

Calling Dispose explicitly from the interoperating code might be necessary for certain interoperation scenarios, because an HwndSource in some interoperation scenarios can generate several references to it across the interoperation boundaries that might prevent timely garbage collection.

Applies to

Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

See also