473,473 Members | 2,034 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Why do plain .NET console or windows applications have a minumum of 3 threads???

Hello,

does anyone know why standard .NET console or windows applications
that do nothing start out with a minimum of 3 threads??? Aren't 3
threads far to many for an application that does nothing??? What are
they for??? Any article around that explains their purpose???
Bob Rock
Nov 16 '05 #1
2 1158
Bob Rock <an***************@yahoo.com> wrote:
does anyone know why standard .NET console or windows applications
that do nothing start out with a minimum of 3 threads??? Aren't 3
threads far to many for an application that does nothing??? What are
they for??? Any article around that explains their purpose???


Well, there's the finalization thread and the main user thread to start
with - that's two off the top of my head. There may well also be
another thread for the GC to monitor memory usage - not sure on that
one. If so, that's explained it all. I wouldn't say that three is
"far" too many anyway - there must be at least one, otherwise no code
would be executing, so at most there are two unnecessary threads, which
is hardly a huge number.

By the way - aren't three question marks after each question also too
many? ;)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
The first thread (an unmanaged thread), is the thread created by the OS
whenever a new Win32 process is started.
The first thread run's the EE (from mscoree.dll) and creates a new thread to
load the CLR.
The second thread runs the CLR , who initializes a managed runtime
environment (AppDomainsf) or your application to run, and creates the
Finalizer thread, and gives control your managed applications "main"
procedure.
The third thread is the finalizer thread.
Note that when you attach a debugger to your process, you will see a fourth
thread which is an unmanaged thread used to run the debugger.

Willy.

"Bob Rock" <an***************@yahoo.com> wrote in message
news:98**************************@posting.google.c om...
Hello,

does anyone know why standard .NET console or windows applications
that do nothing start out with a minimum of 3 threads??? Aren't 3
threads far to many for an application that does nothing??? What are
they for??? Any article around that explains their purpose???
Bob Rock

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Oz | last post by:
This is long. Bear with me, as I will really go through all the convoluted stuff that shows there is a problem with streams (at least when used to redirect stdout). The basic idea is that my...
3
by: Dave | last post by:
I created a console app in Visual Studio 2003 using C#. How to I distribute this app after I build it? It is my understanding that a C# app will run on any machine with the Net Framework...
5
by: Barry Mossman | last post by:
Hi, can I detect whether my class is running within the context of a Console application, vs say a WinForm's application ? also does anyone know whether the compiler or runtime is smart enough...
5
by: David Griffin | last post by:
I have a console application that spawns off several C# threads. It needs to react to shutdown of the system by performing some end of program activities including writing some files and closing...
7
by: Pavils Jurjans | last post by:
Hello, I wanted to get some light in the subject. As I develop ASP.NET applications, it's necessary to understand how exactly the server- communication happens. It seems like initially...
5
by: Tim Werth | last post by:
I have a .NET console application that is kicked off by a .NET Windows service. They communicate via .NET Remoting, although there isn't much communication between the two while the console app is...
2
by: fdmaxey | last post by:
I have used threading in Windows applications successfully. I am trying to write a console application using synchronized threads, as I don't need any display or operator interface. However,...
4
by: Peter Nimmo | last post by:
Hi, I am writting a windows application that I want to be able to act as if it where a Console application in certain circumstances, such as error logging. Whilst I have nearly got it, it...
12
by: Dilip | last post by:
Hi All I have a server based C# console application. This application must hide its console window when its launched out on the field. So I dutifully P/Invoke'd FindWindow/ShowWindow...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.