为什么3线程的基本单线程C#控制台应用程序? [英] Why 3 threads for a basic single threaded c# console app?

查看:405
本文介绍了为什么3线程的基本单线程C#控制台应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了C#中的控制台应用程序有一个到Console.ReadLine 语句。运行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以外的应用程序,我一共有3个线程在Windows任务管理器中看到。为什么有这么多的时候我会想到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.

这篇关于为什么3线程的基本单线程C#控制台应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆