【发布时间】:2010-04-01 09:58:38
【问题描述】:
我遇到的问题是,由于某种原因,ShowDialog 在处理异常后立即返回。但是,它适用于 MessageBox.Show() 或在我第二次调用 ShowDialog 时。解决此问题的最佳方法是什么?
我只能找到this。而且我不敢相信没有其他人有这个问题。
我正在使用 .net 紧凑框架 3.5。示例代码:
try
{
using(SomeForm f = new SomeForm())
{
f.ShowDialog();
}
}
catch(SomeException)
{
using(SomeOtherForm f = new SomeOtherForm())
{
f.ShowDialog(); // this returns immediately
// if this is MessageBox.Show(), it works correctly.
f.ShowDialog(); // then this works fine
}
}
【问题讨论】:
-
在 SomeOtherForm 中编写一个 FormClosing 事件处理程序,在其上设置断点并在它中断时发布您看到的堆栈跟踪。
-
不幸的是没有调用关闭事件。
标签: c# windows-mobile compact-framework