我有一个有两个System.Timers.Timer
对象的类。我现在看到的是,一个抛出的异常被另一个捕获。这是正确的行为吗?
class MyClass {
System.Timers.Timer tOne;
System.Timers.Timer tTwo;
tOne.Elapsed += new System.Timers.ElapsedEventHandler(one);
tTwo.Elapsed += new System.Timers.ElapsedEventHandler(two);
void one(object sender, System.Timers.ElapsedEventArgs e) {
try {
.. some code that throws ...
} catch (Exception) {
// not caught here
}
}
void two(object sender, System.Timers.ElapsedEventArgs e) {
try {
} catch (Exception) {
// but caught here
}
}
}