Thread: thread ID

  1. #1
    Registered User
    Join Date
    May 2006

    thread ID

    Hello everyone,

    I am migrating from C++ to C#. And I am debugging a multi-threaded program and I need to print out the thread ID. In C++, I am using GetCurrentThreadID method, but in C#, I only find Thread.CurrentThread.ManagedThreadId.

    My questions are,


    Does Thread.CurrentThread.ManagedThreadId have the same effect and can serve my purpose?


    I am confused about what means "ManagedThreadId", does there is some peer called "NonManagedThreadId"?

    thanks in advance,

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Hannover, Germany
    The Thread class in C# has a Name property. Setting this property will make debugging much easier, because you can name your threads after what they do and VS will show the names of the running threads while debugging. For example you can name your main thread "UI Thread" and your listener thread "ListenerThread". Those names will appear in VS.

    For seperating threads in your program and identifying them later, you can use the managed thread ID. Name would be easier though

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Thread Synchronization in Win32
    By passionate_guy in forum C Programming
    Replies: 0
    Last Post: 02-06-2006, 05:34 AM
  2. [code] Win32 Thread Object
    By Codeplug in forum Windows Programming
    Replies: 0
    Last Post: 06-03-2005, 03:55 PM
  3. Win32 Thread Object Model Revisted
    By Codeplug in forum Windows Programming
    Replies: 5
    Last Post: 12-15-2004, 08:50 AM
  4. Simple thread object model (my first post)
    By Codeplug in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2004, 11:34 PM
  5. Problem : Threads WILL NOT DIE!!
    By hanhao in forum C++ Programming
    Replies: 2
    Last Post: 04-16-2004, 01:37 PM