线程在捕获异常C#时结束

时间:2016-12-23 11:20:47

标签: c# exception exception-handling argumentexception

所以我有一堆电话。在堆栈的末尾抛出ArgumentException。它传播到最后但有一点,我有这个代码:

    ... Constructor(..){
        try
        {
            this.Issuer = issuer;
            this.Name = name;
            this.Secret = secret;
            this.totpObj = new Totp(secret, 30, 6, mode);
            this.id = Guid.NewGuid().ToString();
            this.mode = mode;
            this.valid = true;
        }
        catch (System.ArgumentException e)
        {
            throw e; // Also tried not having this --> option B

        }
        catch (Exception e)
        {

        }
    }

此代码从此处调用:

private void addButtnClick(object sender, RoutedEventArgs e)
   {
       try
       {
          ...
          TOTPObj totpo = new TOTPObj(af.Accname, af.Issuer, secret, stype); // <--- FAILS
          ...
       }
       catch(Exception ex) //  <--- SHOULD CATCH THIS?!
       {
           Console.WriteLine(ex);
           Environment.Exit(ERROR_FAILED_ADD_KEY);
       }
   }

现在如果我离开&#34;扔&#34;在我得到的第一部分代码中: enter image description here

虽然我认为它应该被提升到一个新的水平? (代码的第二个片段)。

如果我不抛弃异常,只是在那里做事,我就永远不会超越&#34;&lt; --- FAILS&#34;代码块两个,线程刚退出。那是为什么?

0 个答案:

没有答案
相关问题