开发者

Why is a control destroyed twice when it's nested in a tab control?

开发者 https://www.devze.com 2023-01-13 09:04 出处:网络
I\'ve been trying to debug why closing windows forms designer is crashing visual studio and have discovered by adding开发者_如何学Go a series of message boxes that if my controls are nested inside a S

I've been trying to debug why closing windows forms designer is crashing visual studio and have discovered by adding开发者_如何学Go a series of message boxes that if my controls are nested inside a System::Windows::Forms::TabControl the destructor of those controls are called twice.

Is that expected behaviour and is there a way of avoiding it?


The Dispose() method may be called more than once, there is no rule that says it isn't legal. If you do override it (implement the destructor in C++/CLI) then you have to make sure that your code is resilient to this. Very commonly done with an isDisposed field in the class.

0

精彩评论

暂无评论...
验证码 换一张
取 消