1. <i id='IKKPz'><tr id='IKKPz'><dt id='IKKPz'><q id='IKKPz'><span id='IKKPz'><b id='IKKPz'><form id='IKKPz'><ins id='IKKPz'></ins><ul id='IKKPz'></ul><sub id='IKKPz'></sub></form><legend id='IKKPz'></legend><bdo id='IKKPz'><pre id='IKKPz'><center id='IKKPz'></center></pre></bdo></b><th id='IKKPz'></th></span></q></dt></tr></i><div id='IKKPz'><tfoot id='IKKPz'></tfoot><dl id='IKKPz'><fieldset id='IKKPz'></fieldset></dl></div>
  2. <tfoot id='IKKPz'></tfoot>
    • <bdo id='IKKPz'></bdo><ul id='IKKPz'></ul>

    <small id='IKKPz'></small><noframes id='IKKPz'>

    <legend id='IKKPz'><style id='IKKPz'><dir id='IKKPz'><q id='IKKPz'></q></dir></style></legend>

      是什么阻止了 C# 中的线程被收集?

      What prevents a Thread in C# from being Collected?(是什么阻止了 C# 中的线程被收集?)
        <tbody id='EhBxY'></tbody>

      <i id='EhBxY'><tr id='EhBxY'><dt id='EhBxY'><q id='EhBxY'><span id='EhBxY'><b id='EhBxY'><form id='EhBxY'><ins id='EhBxY'></ins><ul id='EhBxY'></ul><sub id='EhBxY'></sub></form><legend id='EhBxY'></legend><bdo id='EhBxY'><pre id='EhBxY'><center id='EhBxY'></center></pre></bdo></b><th id='EhBxY'></th></span></q></dt></tr></i><div id='EhBxY'><tfoot id='EhBxY'></tfoot><dl id='EhBxY'><fieldset id='EhBxY'></fieldset></dl></div>

          <tfoot id='EhBxY'></tfoot>
          <legend id='EhBxY'><style id='EhBxY'><dir id='EhBxY'><q id='EhBxY'></q></dir></style></legend>

              <small id='EhBxY'></small><noframes id='EhBxY'>

                <bdo id='EhBxY'></bdo><ul id='EhBxY'></ul>

              • 本文介绍了是什么阻止了 C# 中的线程被收集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                在 .NET 中,在这段代码之后,什么机制可以阻止 Thread 对象被垃圾回收?

                In .NET, after this code, what mechanism stops the Thread object from being garbage collected?

                new Thread(Foo).Start();
                GC.Collect();
                

                是的,假设 something 引用了该线程是安全的,我只是在徘徊到底是什么.由于某种原因,Reflector 没有向我显示 System.Threading,所以我自己无法挖掘它(我知道 MS 发布了 .NET 框架的源代码,我只是手边没有它).

                Yes, it's safe to assume something has a reference to the thread, I was just wandering what exactly. For some reason Reflector doesn't show me System.Threading, so I can't dig it myself (I know MS released the source code for the .NET framework, I just don't have it handy).

                推荐答案

                运行时只要线程在运行就保持对线程的引用.只要有人仍然保留该引用,GC 就不会收集它.

                The runtime keeps a reference to the thread as long as it is running. The GC wont collect it as long as anyone still keeps that reference.

                这篇关于是什么阻止了 C# 中的线程被收集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                IBM.Data.DB2.Core connection problems(IBM.Data.DB2.Core 连接问题)
                Datetime field overflow with IBM Data Server Client v9.7fp5(IBM Data Server Client v9.7fp5 的日期时间字段溢出)
                Using entity Framework with .NET Core and DB2(将实体框架与 .NET Core 和 DB2 结合使用)
                IBM .NET Data Provider Connection String issue with Library List(库列表的 IBM .NET 数据提供程序连接字符串问题)
                .NET DB2 OLEDB pre-requisites(.NET DB2 OLEDB 先决条件)
                Cannot connect to DB2: IBM.Data.DB2.Core version 3.1.0.400 on Azure Function(无法连接到 DB2:Azure 函数上的 IBM.Data.DB2.Core 版本 3.1.0.400)

                <small id='0fkU2'></small><noframes id='0fkU2'>

                <legend id='0fkU2'><style id='0fkU2'><dir id='0fkU2'><q id='0fkU2'></q></dir></style></legend>

                    <tfoot id='0fkU2'></tfoot>
                      <bdo id='0fkU2'></bdo><ul id='0fkU2'></ul>

                        <tbody id='0fkU2'></tbody>

                          <i id='0fkU2'><tr id='0fkU2'><dt id='0fkU2'><q id='0fkU2'><span id='0fkU2'><b id='0fkU2'><form id='0fkU2'><ins id='0fkU2'></ins><ul id='0fkU2'></ul><sub id='0fkU2'></sub></form><legend id='0fkU2'></legend><bdo id='0fkU2'><pre id='0fkU2'><center id='0fkU2'></center></pre></bdo></b><th id='0fkU2'></th></span></q></dt></tr></i><div id='0fkU2'><tfoot id='0fkU2'></tfoot><dl id='0fkU2'><fieldset id='0fkU2'></fieldset></dl></div>