开发者

Try Catch not executing all lines of code in catch statement C#

开发者 https://www.devze.com 2023-02-17 20:44 出处:网络
I have a try-catch where I try to use an api function for some 3rd party stuff and if it doesn\'t work, I pop up a message box and set a flag. Problem is, the fla开发者_高级运维g doesn\'t get set, eve

I have a try-catch where I try to use an api function for some 3rd party stuff and if it doesn't work, I pop up a message box and set a flag. Problem is, the fla开发者_高级运维g doesn't get set, even though the message box pops up.

I really need to set that SkipThis flag to true since this thing is running on the tick event of a timer and will keep popping up error message boxes if I don't skip it!

try
{
    MachStatus.arUploadFromController();

}
catch (DMCException MyException)
{
    MessageBox.Show("Error#: " + MyException.DMCErrorCode + " - " + MyException.Message);
    SkipThis = true;
}

EDIT: I solved this by putting the SkipThis = true' above the message box line.

0

精彩评论

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