thread ID

This is a discussion on thread ID within the C# Programming forums, part of the General Programming Boards category; Hello everyone, I am migrating from C++ to C#. And I am debugging a multi-threaded program and I need to ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    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,

    1.

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

    2.

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


    thanks in advance,
    George

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    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
    hth
    -nv

    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, 04: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, 02:37 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21