Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / June 2007

Tip: Looking for answers? Try searching our database.

/clr option creates multiple Win32 threads

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
robintw - 12 Jun 2007 10:20 GMT
Hi,

While debugging my application I have noticed that occasionally a message
saying "Win32 Thread xxxx exited with code 0 (0x0)" appearing in the debug
window. I investigated this some more and found that, according to the
threads window, there were four Win32 threads in my program! I had no idea
where these had come from, and was rather worried about what they were doing.

I found that the threads were only there in programs that used a certain
unmanaged DLL that we use for communications. To get the unmanaged DLL to be
linked correctly into our project we have to use the /clr compiler option, as
opposed to the /clr:pure option. After a bit more investigation I have found
that it was setting this option to /clr which seemed to create these extra
Win32 threads.

I've googled a lot about this, as well as searching these newsgroups, and
haven't found anything about this at all. Does anyone know why these threads
are created, what they do, and whether I can have (or need to have) any
control over them?

Cheers,

Robin
SvenC - 12 Jun 2007 10:42 GMT
Hi,

> While debugging my application I have noticed that occasionally a
> message saying "Win32 Thread xxxx exited with code 0 (0x0)" appearing
[quoted text clipped - 14 lines]
> these threads are created, what they do, and whether I can have (or
> need to have) any control over them?

There might be several runtime threads needed by the framework. An obvious
one would be the garbage collector.

Why do you worry? If you'd use COM you would see extra threads for DCOM and
cross apartment calls for objects not able to live in the apartment you
created them in. The OS (or some parts of the OS) has several situations
where additional threads are created.

--
SvenC
robintw - 12 Jun 2007 14:55 GMT
Ok - I just wondered if I needed to worry about them.

I'll just assume they were all created by the CLR or the OS and not worry
about them then!

Thanks,

Robin

> Hi,
>
[quoted text clipped - 27 lines]
> --
> SvenC
Bruno van Dooren - 13 Jun 2007 09:18 GMT
> Ok - I just wondered if I needed to worry about them.
>
> I'll just assume they were all created by the CLR or the OS and not worry
> about them then!

The debugger also has 1 or more threads running when your application is
launched.
Threadpools also start and stop their own threads, so even if your app does
not start extra threads, it is very normal that multiple threads might be
running.

Signature

Kind regards,
   Bruno van Dooren  MVP - VC++
   http://msmvps.com/blogs/vanDooren
   bruno_nos_pam_van_dooren@hotmail.com


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.