开发者

Thread.Abort() when running a debug app hosted in Visual Studio vs. running it directly

开发者 https://www.devze.com 2023-02-17 17:47 出处:网络
We have a thread in which, when we externally call Thread.Abort(), a ThreadAbortException is caught because we have some cleanup to do. In particular, a Mutex is re开发者_开发问答quested. This crashes

We have a thread in which, when we externally call Thread.Abort(), a ThreadAbortException is caught because we have some cleanup to do. In particular, a Mutex is re开发者_开发问答quested. This crashes when running the application in debug mode outside of Visual Studio, but when hosted in Visual Studio, all runs fine. I heard the garbage collector runs differently when hosted vs. when not hosted. Could that have something to do with threads ? The error thrown is a buffer overrun.

Thanks !


As Henk already pointed out, don't call Thread.Abort. Ever.

I have some information on my blog about how the garbage collector works differently in different situations. However, I believe that GC is the same for running a Debug build in or out of the debugger.

If you want other questions answered, you'll need to post more info. "Crashed" is not a descriptive term; does the application suddenly exit, or bring up a dialog you wrote, or bring up Windows Error Reporting? Similarly, I'm not familiar with a "buffer overrun" exception; for an exception, please post the exception type, message, and complete stack trace.

0

精彩评论

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