代码之家  ›  专栏  ›  技术社区  ›  Jan Bannister

使用thread.abort()有什么问题

  •  59
  • Jan Bannister  · 技术社区  · 16 年前

    所以我知道你不应该使用

    Thread.Abort()
    

    但我从来没有得到过一个好的解释。有没有表演惩罚或者一些隐藏的陷阱?

    我知道你不能忽视/吞下苏丹博的感受(这是有道理的)

    7 回复  |  直到 16 年前
        1
  •  76
  •   Eric Lippert    16 年前

        2
  •  17
  •   Damien_The_Unbeliever    16 年前

        3
  •  12
  •   Quibblesome    16 年前

    Monitor.Enter(obj);
    // some code - if exception is raised here, then the lock isn't released
    Monitor.Exit(obj)
    
    IDisposable someCriticalResource = GetResource();
    // some code - if exception is raised here, then the object isn't disposed
    someCriticalResource.Dispose();
    

        4
  •  7
  •   Vasyl Boroviak    16 年前

        5
  •  4
  •   Brian Rasmussen    16 年前

        6
  •  2
  •   Frederik Gheysels    16 年前

        7
  •  1
  •   Vitaliy Liptchinsky    16 年前

    推荐文章