WindowInteropHelper.Handle — do I need to release it?

后端 未结 1 1424
执念已碎
执念已碎 2021-01-28 04:36

In WPF I\'m getting IntPtr handle using this code:

IntPtr mainWindowHandle = new WindowInteropHelper(Application.Current.MainWindow).Handle

Whe

相关标签:
1条回答
  • 2021-01-28 05:04

    This is not in any way related to COM, Marshal.Release() does not apply. You simply get a copy of the native window handle, it does not have to be released. You need to stop using the handle when the window is destroyed. Signaled by the Window.Close event.

    0 讨论(0)
提交回复
热议问题