我的代码如下所示:
class MyUserControl : Control { ...
protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
{
base.OnGotKeyboardFocus(e);
StartDoingSomethingRisky()
}
protected override void OnLostKeyboardFocus(KeyboardFocusChangedEventArgs e)
{
base.OnLostKeyboardFocus(e);
StopDoingSomethingRisky();
}
我是否应该担心在某些情况下我可能会在 MyUserControl 消失后继续进行有风险的操作,或者我是否已经覆盖了 100% 的情况?