[Solved] Destroying the form [closed]


You should call Dispose(). Even if that doesn’t mean all memory gets freed immediately, all resources opened by the form (timers, files, etc.) should be closed then, if the form is programmed properly.

Of course, the form will also be disposed of automatically when the GC runs the next time, but you can make it “disappear” manually by calling Dispose() yourself. Then the GC will run when it feels like running and take care of the memory, but other resources occupied by the window should be released.

The easiest way to do this is:

public static Test() {
    using (Form1 A = new Form1()) {
        // do something with A, but not displaying form
        // I was sure what A will disappears after Test() 
    }
}

4

solved Destroying the form [closed]