Why 3 threads for a basic single threaded c# console app?(为什么一个基本的单线程 C# 控制台应用程序需要 3 个线程?)
问题描述
我使用单个 Console.ReadLine 语句在 c# 中创建了一个控制台应用程序.在 Visual Studio 中运行此应用程序并进入调试器会在线程窗口中显示 7 个线程(6 个工作线程,一个是 .NET SystemEvents,另一个是 vshost.RunParkingWindow 和主线程).
I created a console app in c# with a single Console.ReadLine statement. Running this app within Visual Studio and stepping into the debugger shows 7 threads in the thread window (6 worker threads, one is .NET SystemEvents and the other is vshost.RunParkingWindow and the main thread).
当我在 Visual Studio 之外运行应用程序时,我在 Windows 任务管理器中看到总共 3 个线程.当我期望 1 个线程时,为什么会有这么多?其他人是为了什么而产生的?
When I run the app outside Visual Studio I see a total of 3 threads in Windows task manager. Why so many when I would expect 1 thread? What are the others being spawned for?
推荐答案
如果您正在运行一个 .NET 应用程序,我相信您总是会为 JIT(即时编译器)获得一个线程(主要是休眠)除了你的主线程之外,还有 GC(垃圾收集)线程.
If you're running a .NET application, I believe you always get a thread (mostly sleeping) for the JIT (Just-in-Time compiler) as well as the GC (Garbage Collection) thread, in addition to your main thread.
这篇关于为什么一个基本的单线程 C# 控制台应用程序需要 3 个线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么一个基本的单线程 C# 控制台应用程序需要 3 个线程?
基础教程推荐
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
