By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,946 Members | 744 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,946 IT Pros & Developers. It's quick & easy.

Getting physical thread Id

P: n/a
Hello,
Does anyone know how to get the current thread's ID
in .Net (e.g., for logging purposes)?
The Thread class doesn't have thread Id member. There is
the Process.Threads property, which returns collection of
ProcessThread objects which have IDs, but then how do you
find out which one of them is the current thread?
Thanks,
Hayk
Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Please not that I want to avoid using Win32 API
functions...
Hayk
-----Original Message-----
Hello,
Does anyone know how to get the current thread's ID
in .Net (e.g., for logging purposes)?
The Thread class doesn't have thread Id member. There is
the Process.Threads property, which returns collection of
ProcessThread objects which have IDs, but then how do you
find out which one of them is the current thread?
Thanks,
Hayk
.

Jul 19 '05 #2

P: n/a
The Thread class doesn't have thread Id member.


But it does have the GetHashCode() which is good enough for most
purposes.

There's also the AppDomain.GetCurrentThreadId() method.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.