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. Start process

Start process

Scheduled Pinned Locked Moved C#
questiongraphicshelp
10 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.
  • G Offline
    G Offline
    gapfulgence
    wrote on last edited by
    #1

    Hi, I start a process using the Process.Start method with appropriate arguments. I can see that the process is created. However, when I try to get a handler on the process's main window , I get 0. It seems to be because the process doesn't already have finished drawing itself. How can I resolve this problem ? Thanks !

    p.f. Goudjo-Ako Bringing our energy together !

    L D 2 Replies Last reply
    0
    • G gapfulgence

      Hi, I start a process using the Process.Start method with appropriate arguments. I can see that the process is created. However, when I try to get a handler on the process's main window , I get 0. It seems to be because the process doesn't already have finished drawing itself. How can I resolve this problem ? Thanks !

      p.f. Goudjo-Ako Bringing our energy together !

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Hi Hope this will help you even if I had a feel that my way is stupid ... bool GetHandle; GetHandle= false; // Wait for 100 MillliSecond Before Get the Handle int WaitingTime = 100; Process pr = Process.Start("NotePad.exe"); while (GetHandle) { if (pr.StartTime.Ticks <= (DateTime.Now.Ticks - WaitingTime)) { GetHandle = true; } } // Getting Handle ( as String just to know it's value ) MessageBox.Show (Handle.ToString()); Have a good day ....

      I know nothing , I know nothing

      G 2 Replies Last reply
      0
      • L Lost User

        Hi Hope this will help you even if I had a feel that my way is stupid ... bool GetHandle; GetHandle= false; // Wait for 100 MillliSecond Before Get the Handle int WaitingTime = 100; Process pr = Process.Start("NotePad.exe"); while (GetHandle) { if (pr.StartTime.Ticks <= (DateTime.Now.Ticks - WaitingTime)) { GetHandle = true; } } // Getting Handle ( as String just to know it's value ) MessageBox.Show (Handle.ToString()); Have a good day ....

        I know nothing , I know nothing

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

        I'm going to try ur suggestion. There's no stupid idea ! never ! Thanks a lor for helping. I'll be back with comments.

        p.f. Goudjo-Ako Bringing our energy together !

        1 Reply Last reply
        0
        • L Lost User

          Hi Hope this will help you even if I had a feel that my way is stupid ... bool GetHandle; GetHandle= false; // Wait for 100 MillliSecond Before Get the Handle int WaitingTime = 100; Process pr = Process.Start("NotePad.exe"); while (GetHandle) { if (pr.StartTime.Ticks <= (DateTime.Now.Ticks - WaitingTime)) { GetHandle = true; } } // Getting Handle ( as String just to know it's value ) MessageBox.Show (Handle.ToString()); Have a good day ....

          I know nothing , I know nothing

          G Offline
          G Offline
          gapfulgence
          wrote on last edited by
          #4

          Since you start by intializing GetHandle to false, we'll never enter in the while loop. No ?

          p.f. Goudjo-Ako Bringing our energy together !

          L 1 Reply Last reply
          0
          • G gapfulgence

            Since you start by intializing GetHandle to false, we'll never enter in the while loop. No ?

            p.f. Goudjo-Ako Bringing our energy together !

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            yeah yeah you right x10 , sorry I just write it fast , you can fix the loop right ? and may be you can use for (int i =0 ; i<= 1000 ; i++) { Application.DoEvents(); } it's just about the idea , agree ?

            I know nothing , I know nothing

            G 2 Replies Last reply
            0
            • L Lost User

              yeah yeah you right x10 , sorry I just write it fast , you can fix the loop right ? and may be you can use for (int i =0 ; i<= 1000 ; i++) { Application.DoEvents(); } it's just about the idea , agree ?

              I know nothing , I know nothing

              G Offline
              G Offline
              gapfulgence
              wrote on last edited by
              #6

              Yeah, you're right ! What about the following little modification of your first code ? bool getHandle = true; int waitingTime = 300; while (getHandle) { if (InterProcCommunication.CurrentProcess.StartTime.Ticks <= (DateTime.Now.Ticks - waitingTime)) { getHandle = true; } else { getHandle = false; }

              p.f. Goudjo-Ako Bringing our energy together !

              1 Reply Last reply
              0
              • L Lost User

                yeah yeah you right x10 , sorry I just write it fast , you can fix the loop right ? and may be you can use for (int i =0 ; i<= 1000 ; i++) { Application.DoEvents(); } it's just about the idea , agree ?

                I know nothing , I know nothing

                G Offline
                G Offline
                gapfulgence
                wrote on last edited by
                #7

                We can also use Thread.Sleep(time);

                p.f. Goudjo-Ako Bringing our energy together !

                1 Reply Last reply
                0
                • G gapfulgence

                  Hi, I start a process using the Process.Start method with appropriate arguments. I can see that the process is created. However, when I try to get a handler on the process's main window , I get 0. It seems to be because the process doesn't already have finished drawing itself. How can I resolve this problem ? Thanks !

                  p.f. Goudjo-Ako Bringing our energy together !

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

                  Uhhh...Instead of going through the timer garbage, which can be unreliable depending on system load, why not just do it in a single line of code?

                  Process newProc = Process.Start(newProcessInfo);
                  newProc.WaitForInputIdle();

                  Doc on it are here[^].

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

                  L G 2 Replies Last reply
                  0
                  • D Dave Kreskowiak

                    Uhhh...Instead of going through the timer garbage, which can be unreliable depending on system load, why not just do it in a single line of code?

                    Process newProc = Process.Start(newProcessInfo);
                    newProc.WaitForInputIdle();

                    Doc on it are here[^].

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

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    cool !! man , I didn't know that :rolleyes: it's just awesome

                    I know nothing , I know nothing

                    1 Reply Last reply
                    0
                    • D Dave Kreskowiak

                      Uhhh...Instead of going through the timer garbage, which can be unreliable depending on system load, why not just do it in a single line of code?

                      Process newProc = Process.Start(newProcessInfo);
                      newProc.WaitForInputIdle();

                      Doc on it are here[^].

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

                      G Offline
                      G Offline
                      gapfulgence
                      wrote on last edited by
                      #10

                      This is interesting ! It does the same thing than using the Thread.Sleep(time) with a constant check of the handle on the process's main window, but in BETTER and MORE SIMPLE. Thanks !

                      p.f. Goudjo-Ako Bringing our energy together !

                      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