在窗体上的我的加载事件中,我调用try catch块中的某个方法。发生异常时,我向用户显示一条消息,之后我想关闭表单。它看起来像这样(代码Load事件):为什么Close()在加载事件中关闭窗体?
try
{
Metehod();
}
catch(DatabaseException ex)
{
MessageBox.show("db error! " + ex.Message);
this.Close();
}
catch(Exception ex)
{
MessageBox.Show("Unknown error!" + ex.Message);
this.Close();
}
但是,当this.CLose()
被调用,它不关闭的形式,没有,代码继续运行,直至负荷事件的结束!
这是为什么?这是合乎逻辑的行为?