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. Quick Threading Question

Quick Threading Question

Scheduled Pinned Locked Moved C#
question
5 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.
  • M Offline
    M Offline
    Mr Rogers
    wrote on last edited by
    #1

    How do you spin a process off onto another thread and wait for it to complete? I'm looking for something like when you call ShowDialog and the process stops until the dialog has been closed.

    S 1 Reply Last reply
    0
    • M Mr Rogers

      How do you spin a process off onto another thread and wait for it to complete? I'm looking for something like when you call ShowDialog and the process stops until the dialog has been closed.

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

      You are looking for the WaitForExit[^] method on the Process[^] class. Regards Senthil _____________________________ My Blog | My Articles | WinMacro

      M 1 Reply Last reply
      0
      • S S Senthil Kumar

        You are looking for the WaitForExit[^] method on the Process[^] class. Regards Senthil _____________________________ My Blog | My Articles | WinMacro

        M Offline
        M Offline
        Mr Rogers
        wrote on last edited by
        #3

        Cool, thanks. I'll take a look at it.

        M 1 Reply Last reply
        0
        • M Mr Rogers

          Cool, thanks. I'll take a look at it.

          M Offline
          M Offline
          Mark Greenwood
          wrote on last edited by
          #4

          If your question was how to kick off a seperate process (e.g. another application) from within you current program then the previous answer will be the key, however it looked from your question as if you wanted to kick off a seperate THREAD from within your program, in that case you would create a new thread, start it off and then call Join to wait for it to finish. e.g ThreadStart ts = new ThreadStart(StartExtrapolation); // Name of some void function Thread thThread = new Thread(ts); thThread.Start(); thThread.Join(); // Can take a timeout variable as well if you want // Any code after this will either happen after the thread has finished or if a timeout occured

          M 1 Reply Last reply
          0
          • M Mark Greenwood

            If your question was how to kick off a seperate process (e.g. another application) from within you current program then the previous answer will be the key, however it looked from your question as if you wanted to kick off a seperate THREAD from within your program, in that case you would create a new thread, start it off and then call Join to wait for it to finish. e.g ThreadStart ts = new ThreadStart(StartExtrapolation); // Name of some void function Thread thThread = new Thread(ts); thThread.Start(); thThread.Join(); // Can take a timeout variable as well if you want // Any code after this will either happen after the thread has finished or if a timeout occured

            M Offline
            M Offline
            Mr Rogers
            wrote on last edited by
            #5

            Yeah, a separate thread yes. I've known how to start different threads and whatnot, just didn't ever know how to wait for one to finish without some kind of event. Thanks.

            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