Should you be disposed of using CommonDialog?

The use of code blocks or the Dispose method was not used in this MSDN dialog box example.

But why is it not located even though it has a Dispose method?

+3
source share
3 answers

Frowning, unfortunately, is not crystal clear. OpenFileDialog and friends inherit Dispose () from the Component class. Each component must implement Dispose () because the form's Dispose () method calls it. It just so happens that there are several component-based classes that have the Dispose () do-nothing method. Dialog classes are like these, these are dialogs. They clean up any unmanaged resources when the dialog closes. No further assistance is required.

. , MSDN , , . , Component.Dispose() ( ). , , using. Dispose(), . , , - .

+2

, , () (, , ), .

, , ?

0

The garbage collector will clear after you if you have not explicitly named Dispose().
Most of the time, you can rely on the garbage collector to do this for you, unless you are very well versed in using minute memory after each build.

0
source

Source: https://habr.com/ru/post/1773992/


All Articles