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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. waitforexit

waitforexit

Scheduled Pinned Locked Moved Visual Basic
helpcareer
8 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.
  • H Offline
    H Offline
    hrishi321
    wrote on last edited by
    #1

    Hi, Another problem of mine. I run a process(say a calculator) from a button click. Now I want to resume(do nothing/disable) the form till the user finishes the process ie till he closes the calculator. I am using waitforexit like below(not the exact code) dim p as new process p.startinfo="calc" p.waitforexit() p.start() It works fine,.But sometime it gives an error in the line(p.waiforexit) saying that p has not been allocated any process (not the exact error, but with similar measning) Please help me Thanks in advance

    D 1 Reply Last reply
    0
    • H hrishi321

      Hi, Another problem of mine. I run a process(say a calculator) from a button click. Now I want to resume(do nothing/disable) the form till the user finishes the process ie till he closes the calculator. I am using waitforexit like below(not the exact code) dim p as new process p.startinfo="calc" p.waitforexit() p.start() It works fine,.But sometime it gives an error in the line(p.waiforexit) saying that p has not been allocated any process (not the exact error, but with similar measning) Please help me Thanks in advance

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      This is because your Waiting for the process to exist before you start the process! You can't wait for something to exit if it doesn't exist yet! Switch those two lines around and it'll work.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008

      H 2 Replies Last reply
      0
      • D Dave Kreskowiak

        This is because your Waiting for the process to exist before you start the process! You can't wait for something to exit if it doesn't exist yet! Switch those two lines around and it'll work.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007, 2008

        H Offline
        H Offline
        hrishi321
        wrote on last edited by
        #3

        thanks for your reply i think u r mistaking me. its waitforexit not exist...

        H D 2 Replies Last reply
        0
        • H hrishi321

          thanks for your reply i think u r mistaking me. its waitforexit not exist...

          H Offline
          H Offline
          Henry Minute
          wrote on last edited by
          #4

          himangshu123 wrote:

          i think u r mistaking me.

          No but you are mistaking him. Dave Kreskowiak correctly pointed out that your code waits for exit before it starts. It should start and then wait for exit;

          p.waitforexit()
          p.start()

          switch those two lines round then all should be well. Incidentally in your OP you stated that the code you posted was not the exact code, and the error message was not the exact error message. In this case it doesn't seem to have made any difference, but you really should (particularly for error messages), give the exact wording.

          Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

          H 1 Reply Last reply
          0
          • H Henry Minute

            himangshu123 wrote:

            i think u r mistaking me.

            No but you are mistaking him. Dave Kreskowiak correctly pointed out that your code waits for exit before it starts. It should start and then wait for exit;

            p.waitforexit()
            p.start()

            switch those two lines round then all should be well. Incidentally in your OP you stated that the code you posted was not the exact code, and the error message was not the exact error message. In this case it doesn't seem to have made any difference, but you really should (particularly for error messages), give the exact wording.

            Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

            H Offline
            H Offline
            hrishi321
            wrote on last edited by
            #5

            oh apologise me... my mistake... actually I have done the same...i didnt cut copy the code so that mistake came...sorry... please help me

            1 Reply Last reply
            0
            • D Dave Kreskowiak

              This is because your Waiting for the process to exist before you start the process! You can't wait for something to exit if it doesn't exist yet! Switch those two lines around and it'll work.

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                   2006, 2007, 2008

              H Offline
              H Offline
              hrishi321
              wrote on last edited by
              #6

              sorry.... code is dim p as new process p.startinfo="calc" p.start() p.waitforexit() this was my actual code still the problem arise

              D 1 Reply Last reply
              0
              • H hrishi321

                thanks for your reply i think u r mistaking me. its waitforexit not exist...

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #7

                A very minor typo.

                A guide to posting questions on CodeProject[^]
                Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                     2006, 2007, 2008

                1 Reply Last reply
                0
                • H hrishi321

                  sorry.... code is dim p as new process p.startinfo="calc" p.start() p.waitforexit() this was my actual code still the problem arise

                  D Offline
                  D Offline
                  Dave Kreskowiak
                  wrote on last edited by
                  #8

                  Next time, copy and paste the code. Don't retype it from memory. You'll get the order of statements wrong and quite possibly not convey some minor detail that makes all the difference to whether your code runs or not. Between the call to .Start and .WaitForExit, add the line p.WaitForInputIdle(). This will force your code to wait for the app to start.

                  A guide to posting questions on CodeProject[^]
                  Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                       2006, 2007, 2008

                  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