Is it safe to call close on a form and then call close again on it. no other operations are being done with it after the first close.
my suspicion is that this is bad and it is effectively racing the GC to call the second close? (and winning 99.999% of the time so I’m not seeing any error)
Edit: to be clear this is IMHO a bug, but it is not currently causing any exception to be thrown. the problem is more how big an issue is it? should I fix the one I’ve found and move on because it’s relatively benign, or should I review every form in the design to make sure there isn’t any similar issue on the grounds that the lack of exception may depend on GC behaviour.
The second call isn’t going to close the native window anymore, it’s gone. It will just call Dispose() again. Which is fine, disposing an object multiple times is supported in all .NET classes.
None of this has anything to do with the garbage collector, clearly you still have a reference to the form object or you wouldn’t have been able to call Close(). Don’t keep this reference around forever or you’ll leak the form object. It is otherwise dead and can’t be revived. Referencing members of that form object tends to throw ObjectDisposedException.