Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Thread ID for current thread

Thread ID for current thread

Scheduled Pinned Locked Moved C#
mcptutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Grimolfr
    wrote on last edited by
    #1

    for logging purposes, I need to be able to determine the thread ID of the currently executing thread. I've discovered that I can pretty easily get the thread ID from the ProcessThread class. What I can't figure out is how to determine which ProcessThread corresponds to System.Threading.Thread.CurrentThread. Any tips on how to get the ID that I'm looking for? BTW, I've already tried using Thread.CurrentThread.GetHashCode(). While it seems to work (unique numbers), a comparison to the ProcessThread IDs in the app makes it perfectly clear that there's no direct correlation.


    Grim

    (aka Toby)

    MCDBA, MCSD, MCP+SB

    J 1 Reply Last reply
    0
    • G Grimolfr

      for logging purposes, I need to be able to determine the thread ID of the currently executing thread. I've discovered that I can pretty easily get the thread ID from the ProcessThread class. What I can't figure out is how to determine which ProcessThread corresponds to System.Threading.Thread.CurrentThread. Any tips on how to get the ID that I'm looking for? BTW, I've already tried using Thread.CurrentThread.GetHashCode(). While it seems to work (unique numbers), a comparison to the ProcessThread IDs in the app makes it perfectly clear that there's no direct correlation.


      Grim

      (aka Toby)

      MCDBA, MCSD, MCP+SB

      J Offline
      J Offline
      jqd2001
      wrote on last edited by
      #2

      I used the following two: System.Diagnositics.ProcessThread Id Property AppDomain.GetCurrentThreadId() The former is OS Thread ( so Process) The latter is CLR Thread ( so AppDomain) Is that what you are look for ? Any other ways ?? James

      G 1 Reply Last reply
      0
      • J jqd2001

        I used the following two: System.Diagnositics.ProcessThread Id Property AppDomain.GetCurrentThreadId() The former is OS Thread ( so Process) The latter is CLR Thread ( so AppDomain) Is that what you are look for ? Any other ways ?? James

        G Offline
        G Offline
        Grimolfr
        wrote on last edited by
        #3

        Thanks, James. The AppDomain is what I was looking for.


        Grim

        (aka Toby)

        MCDBA, MCSD, MCP+SB

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups