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. Determine if a thread has been instantiated

Determine if a thread has been instantiated

Scheduled Pinned Locked Moved C#
question
4 Posts 3 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.
  • R Offline
    R Offline
    raysot777
    wrote on last edited by
    #1

    I am trying to find a way to determine if a thread object has been instantiated. Not if it's been started/stopped/suspended, etc, but instantiated/declared: ie: t = new Thread(new ThreadStart(FSUIPC_Handler)); if(t exists) { t.Start(); } How could I determine if "t" exists?

    M S 2 Replies Last reply
    0
    • R raysot777

      I am trying to find a way to determine if a thread object has been instantiated. Not if it's been started/stopped/suspended, etc, but instantiated/declared: ie: t = new Thread(new ThreadStart(FSUIPC_Handler)); if(t exists) { t.Start(); } How could I determine if "t" exists?

      M Offline
      M Offline
      Mohamad Al Husseiny
      wrote on last edited by
      #2

      You can write some thing like the following

       if(t != null)
         {
            t.Start();
         }
      

      MCAD

      R 1 Reply Last reply
      0
      • R raysot777

        I am trying to find a way to determine if a thread object has been instantiated. Not if it's been started/stopped/suspended, etc, but instantiated/declared: ie: t = new Thread(new ThreadStart(FSUIPC_Handler)); if(t exists) { t.Start(); } How could I determine if "t" exists?

        S Offline
        S Offline
        S Senthil Kumar
        wrote on last edited by
        #3

        Would checking for null help?

        t = new Thread(new ThreadStart(FSUIPC_Handler));

        if (t != null)
        {
        ...
        }

        Regards Senthil _____________________________ My Blog | My Articles | WinMacro

        1 Reply Last reply
        0
        • M Mohamad Al Husseiny

          You can write some thing like the following

           if(t != null)
             {
                t.Start();
             }
          

          MCAD

          R Offline
          R Offline
          raysot777
          wrote on last edited by
          #4

          That works! Thank you!!

          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