GetProcesses hangs on XP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tomas Vera

    GetProcesses hangs on XP

    Hello All,
    I'ma having trouble getting GetCurrentProce ss() to work properly.
    What I'm trying to accomplish is list all running processes. But my
    call get GetProcesses() hangs.

    While testing things out I found that the tiny program listed below
    hangs as well.

    Am I missing something?

    -tomas


    //---- This app hangs ----
    using System;
    using System.Diagnost ics;

    namespace proctest
    {

    class Class1
    {

    [STAThread]
    static void Main(string[] args)
    {

    Console.WriteLi ne(Process.GetC urrentProcess() .ProcessName);
    }
    }
    }

    // -- What's wrong with this code?


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: GetProcesses hangs on XP

    Tomas,

    Getting the process information can take a while. It's most likely that
    it is not hanging, but just you have a lot of processes running on your
    machine.

    How many processes do you see in task manager when it comes up? Have
    you let it run, and attempted to let it finish?


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Tomas Vera" <taveraNOSPAM@s bcglobalREMOVE. net> wrote in message
    news:8gusk158mc vfo7f6c9npsi4gb 491poc426@4ax.c om...[color=blue]
    > Hello All,
    > I'ma having trouble getting GetCurrentProce ss() to work properly.
    > What I'm trying to accomplish is list all running processes. But my
    > call get GetProcesses() hangs.
    >
    > While testing things out I found that the tiny program listed below
    > hangs as well.
    >
    > Am I missing something?
    >
    > -tomas
    >
    >
    > //---- This app hangs ----
    > using System;
    > using System.Diagnost ics;
    >
    > namespace proctest
    > {
    >
    > class Class1
    > {
    >
    > [STAThread]
    > static void Main(string[] args)
    > {
    >
    > Console.WriteLi ne(Process.GetC urrentProcess() .ProcessName);
    > }
    > }
    > }
    >
    > // -- What's wrong with this code?
    >
    >[/color]


    Comment

    • Tomas Vera

      #3
      Re: GetProcesses hangs on XP

      Nicholas,
      Thanks for your reply.

      There are about 60 processes running.
      I've let the app wait for about 4 minutes. Is this typical?

      Thanks for your help.

      -tomas


      On Thu, 13 Oct 2005 11:38:07 -0400, "Nicholas Paldino [.NET/C# MVP]"
      <mvp@spam.guard .caspershouse.c om> wrote:
      [color=blue]
      >Tomas,
      >
      > Getting the process information can take a while. It's most likely that
      >it is not hanging, but just you have a lot of processes running on your
      >machine.
      >
      > How many processes do you see in task manager when it comes up? Have
      >you let it run, and attempted to let it finish?[/color]

      Comment

      • Nicholas Paldino [.NET/C# MVP]

        #4
        Re: GetProcesses hangs on XP

        Tomas,

        That is a good number of processes. What information are you trying to
        retreive from the processes? It might be better to use WMI instead.


        --
        - Nicholas Paldino [.NET/C# MVP]
        - mvp@spam.guard. caspershouse.co m

        "Tomas Vera" <taveraNOSPAM@s bcglobalREMOVE. net> wrote in message
        news:p37tk1p8bk ntamnmh7741upcs g1koh5p61@4ax.c om...[color=blue]
        > Nicholas,
        > Thanks for your reply.
        >
        > There are about 60 processes running.
        > I've let the app wait for about 4 minutes. Is this typical?
        >
        > Thanks for your help.
        >
        > -tomas
        >
        >
        > On Thu, 13 Oct 2005 11:38:07 -0400, "Nicholas Paldino [.NET/C# MVP]"
        > <mvp@spam.guard .caspershouse.c om> wrote:
        >[color=green]
        >>Tomas,
        >>
        >> Getting the process information can take a while. It's most likely
        >> that
        >>it is not hanging, but just you have a lot of processes running on your
        >>machine.
        >>
        >> How many processes do you see in task manager when it comes up? Have
        >>you let it run, and attempted to let it finish?[/color]
        >[/color]


        Comment

        • Willy Denoyette [MVP]

          #5
          Re: GetProcesses hangs on XP


          "Tomas Vera" <taveraNOSPAM@s bcglobalREMOVE. net> wrote in message
          news:8gusk158mc vfo7f6c9npsi4gb 491poc426@4ax.c om...[color=blue]
          > Hello All,
          > I'ma having trouble getting GetCurrentProce ss() to work properly.
          > What I'm trying to accomplish is list all running processes. But my
          > call get GetProcesses() hangs.
          >
          > While testing things out I found that the tiny program listed below
          > hangs as well.
          >
          > Am I missing something?
          >
          > -tomas
          >
          >
          > //---- This app hangs ----
          > using System;
          > using System.Diagnost ics;
          >
          > namespace proctest
          > {
          >
          > class Class1
          > {
          >
          > [STAThread]
          > static void Main(string[] args)
          > {
          >
          > Console.WriteLi ne(Process.GetC urrentProcess() .ProcessName);
          > }
          > }
          > }
          >
          > // -- What's wrong with this code?
          >
          >[/color]

          This tiny program should return within seconds. What version of XP (SP) and
          ..NET are you running?
          Are you running this as domain user or as a local user, how many user tokens
          do you have in you account group?

          Willy.



          Comment

          • Tomas Vera

            #6
            Re: GetProcesses hangs on XP

            Nicholas,

            Eventually, I need to be able to detect and use existing instances of
            MS Excel and Word for some applications that I'm developing. But I've
            only been playing with processes for about 2 days.

            So in the short term, I'm simply trying to get the process names to
            display them. I didn't expect that this should take as long as it
            does.

            I'll try it again this evening.

            Thanks for your help.

            -tomas


            On Thu, 13 Oct 2005 13:46:53 -0400, "Nicholas Paldino [.NET/C# MVP]"
            <mvp@spam.guard .caspershouse.c om> wrote:
            [color=blue]
            >Tomas,
            >
            > That is a good number of processes. What information are you trying to
            >retreive from the processes? It might be better to use WMI instead.[/color]

            Comment

            • Tomas Vera

              #7
              Re: GetProcesses hangs on XP

              Willy,
              I'm running in XP SP2 (.NET 1.1.4322)

              I'm running as a local user on my laptop. Only 1 user on the machine.

              One thing to note: if I use this code:

              private void TestFunction()
              {
              Process proc;
              proc = Process.GetCurr entProcess();
              string procName = proc.ProcessNam e; <-- HANGS HERE
              Console.WriteLi ne(procName);
              }

              The "proc =" assignment returns as expected. But if I try to examine
              the properties of "proc" (in the debugger), "proc" it looks like an
              uninitialized object.
              Then the "procName=" line hangs (or appears to hang).

              I still need to try elimintating all the unnecessary processes and
              waiting longer, (as suggested by Nicholas) to see if that allows the
              app to work.

              But I don't understand why the "proc=" line return what appears to be
              an improperly init'd object.

              Thanks for your help.

              -tomas

              On Thu, 13 Oct 2005 22:37:22 +0200, "Willy Denoyette [MVP]"
              <willy.denoyett e@telenet.be> wrote:
              [color=blue]
              >
              >"Tomas Vera" <taveraNOSPAM@s bcglobalREMOVE. net> wrote in message
              >news:8gusk158m cvfo7f6c9npsi4g b491poc426@4ax. com...[color=green]
              >> Hello All,
              >> I'ma having trouble getting GetCurrentProce ss() to work properly.
              >> What I'm trying to accomplish is list all running processes. But my
              >> call get GetProcesses() hangs.
              >>
              >> While testing things out I found that the tiny program listed below
              >> hangs as well.
              >>
              >> Am I missing something?
              >>
              >> -tomas
              >>
              >>
              >> //---- This app hangs ----
              >> using System;
              >> using System.Diagnost ics;
              >>
              >> namespace proctest
              >> {
              >>
              >> class Class1
              >> {
              >>
              >> [STAThread]
              >> static void Main(string[] args)
              >> {
              >>
              >> Console.WriteLi ne(Process.GetC urrentProcess() .ProcessName);
              >> }
              >> }
              >> }
              >>
              >> // -- What's wrong with this code?
              >>
              >>[/color]
              >
              >This tiny program should return within seconds. What version of XP (SP) and
              >.NET are you running?
              >Are you running this as domain user or as a local user, how many user tokens
              >do you have in you account group?
              >
              >Willy.
              >
              >[/color]

              Comment

              • Willy Denoyette [MVP]

                #8
                Re: GetProcesses hangs on XP

                Tomas,

                How does this tiny program behaves when run from the commandline (in debug
                or retail version).

                Willy.
                PS did you install SP1 for .NET 1.1.4322 ?


                "Tomas Vera" <taveraNOSPAM@s bcglobalREMOVE. net> wrote in message
                news:3ontk116mi qtn5a8kbgubmllf v7058f7fq@4ax.c om...[color=blue]
                > Willy,
                > I'm running in XP SP2 (.NET 1.1.4322)
                >
                > I'm running as a local user on my laptop. Only 1 user on the machine.
                >
                > One thing to note: if I use this code:
                >
                > private void TestFunction()
                > {
                > Process proc;
                > proc = Process.GetCurr entProcess();
                > string procName = proc.ProcessNam e; <-- HANGS HERE
                > Console.WriteLi ne(procName);
                > }
                >
                > The "proc =" assignment returns as expected. But if I try to examine
                > the properties of "proc" (in the debugger), "proc" it looks like an
                > uninitialized object.
                > Then the "procName=" line hangs (or appears to hang).
                >
                > I still need to try elimintating all the unnecessary processes and
                > waiting longer, (as suggested by Nicholas) to see if that allows the
                > app to work.
                >
                > But I don't understand why the "proc=" line return what appears to be
                > an improperly init'd object.
                >
                > Thanks for your help.
                >
                > -tomas
                >
                > On Thu, 13 Oct 2005 22:37:22 +0200, "Willy Denoyette [MVP]"
                > <willy.denoyett e@telenet.be> wrote:
                >[color=green]
                >>
                >>"Tomas Vera" <taveraNOSPAM@s bcglobalREMOVE. net> wrote in message
                >>news:8gusk158 mcvfo7f6c9npsi4 gb491poc426@4ax .com...[color=darkred]
                >>> Hello All,
                >>> I'ma having trouble getting GetCurrentProce ss() to work properly.
                >>> What I'm trying to accomplish is list all running processes. But my
                >>> call get GetProcesses() hangs.
                >>>
                >>> While testing things out I found that the tiny program listed below
                >>> hangs as well.
                >>>
                >>> Am I missing something?
                >>>
                >>> -tomas
                >>>
                >>>
                >>> //---- This app hangs ----
                >>> using System;
                >>> using System.Diagnost ics;
                >>>
                >>> namespace proctest
                >>> {
                >>>
                >>> class Class1
                >>> {
                >>>
                >>> [STAThread]
                >>> static void Main(string[] args)
                >>> {
                >>>
                >>> Console.WriteLi ne(Process.GetC urrentProcess() .ProcessName);
                >>> }
                >>> }
                >>> }
                >>>
                >>> // -- What's wrong with this code?
                >>>
                >>>[/color]
                >>
                >>This tiny program should return within seconds. What version of XP (SP)
                >>and
                >>.NET are you running?
                >>Are you running this as domain user or as a local user, how many user
                >>tokens
                >>do you have in you account group?
                >>
                >>Willy.
                >>
                >>[/color]
                >[/color]


                Comment

                • Tomas Vera

                  #9
                  Re: GetProcesses hangs on XP

                  Willy,
                  There is no difference when run from the IDE or from the command line.
                  There is no difference between RELEASE and DEBUG builds.


                  SP1 for .NET 1.1.4322 is NOT installed.

                  But, this is not critical, just fustrating. Just trying to learn
                  something new.

                  -tomas





                  On Fri, 14 Oct 2005 00:53:13 +0200, "Willy Denoyette [MVP]"
                  <willy.denoyett e@telenet.be> wrote:
                  [color=blue]
                  >Tomas,
                  >
                  >How does this tiny program behaves when run from the commandline (in debug
                  >or retail version).
                  >
                  >Willy.
                  >PS did you install SP1 for .NET 1.1.4322 ?
                  >
                  >
                  >"Tomas Vera" <taveraNOSPAM@s bcglobalREMOVE. net> wrote in message
                  >news:3ontk116m iqtn5a8kbgubmll fv7058f7fq@4ax. com...[color=green]
                  >> Willy,
                  >> I'm running in XP SP2 (.NET 1.1.4322)
                  >>
                  >> I'm running as a local user on my laptop. Only 1 user on the machine.
                  >>
                  >> One thing to note: if I use this code:
                  >>
                  >> private void TestFunction()
                  >> {
                  >> Process proc;
                  >> proc = Process.GetCurr entProcess();
                  >> string procName = proc.ProcessNam e; <-- HANGS HERE
                  >> Console.WriteLi ne(procName);
                  >> }
                  >>
                  >> The "proc =" assignment returns as expected. But if I try to examine
                  >> the properties of "proc" (in the debugger), "proc" it looks like an
                  >> uninitialized object.
                  >> Then the "procName=" line hangs (or appears to hang).
                  >>
                  >> I still need to try elimintating all the unnecessary processes and
                  >> waiting longer, (as suggested by Nicholas) to see if that allows the
                  >> app to work.
                  >>
                  >> But I don't understand why the "proc=" line return what appears to be
                  >> an improperly init'd object.
                  >>
                  >> Thanks for your help.
                  >>
                  >> -tomas
                  >>
                  >> On Thu, 13 Oct 2005 22:37:22 +0200, "Willy Denoyette [MVP]"
                  >> <willy.denoyett e@telenet.be> wrote:
                  >>[color=darkred]
                  >>>
                  >>>"Tomas Vera" <taveraNOSPAM@s bcglobalREMOVE. net> wrote in message
                  >>>news:8gusk15 8mcvfo7f6c9npsi 4gb491poc426@4a x.com...
                  >>>> Hello All,
                  >>>> I'ma having trouble getting GetCurrentProce ss() to work properly.
                  >>>> What I'm trying to accomplish is list all running processes. But my
                  >>>> call get GetProcesses() hangs.
                  >>>>
                  >>>> While testing things out I found that the tiny program listed below
                  >>>> hangs as well.
                  >>>>
                  >>>> Am I missing something?
                  >>>>
                  >>>> -tomas
                  >>>>
                  >>>>
                  >>>> //---- This app hangs ----
                  >>>> using System;
                  >>>> using System.Diagnost ics;
                  >>>>
                  >>>> namespace proctest
                  >>>> {
                  >>>>
                  >>>> class Class1
                  >>>> {
                  >>>>
                  >>>> [STAThread]
                  >>>> static void Main(string[] args)
                  >>>> {
                  >>>>
                  >>>> Console.WriteLi ne(Process.GetC urrentProcess() .ProcessName);
                  >>>> }
                  >>>> }
                  >>>> }
                  >>>>
                  >>>> // -- What's wrong with this code?
                  >>>>
                  >>>>
                  >>>
                  >>>This tiny program should return within seconds. What version of XP (SP)
                  >>>and
                  >>>.NET are you running?
                  >>>Are you running this as domain user or as a local user, how many user
                  >>>tokens
                  >>>do you have in you account group?
                  >>>
                  >>>Willy.
                  >>>
                  >>>[/color]
                  >>[/color]
                  >[/color]

                  Comment

                  • Nicholas Paldino [.NET/C# MVP]

                    #10
                    Re: GetProcesses hangs on XP

                    Tomas,

                    If you are trying to get existing instances of Excel and Word, you
                    shouldn't have to enumerate through the processes. You should be able to
                    use the static GetActiveObject method on the Marshal class to automate
                    running instances of Excel and Word.


                    --
                    - Nicholas Paldino [.NET/C# MVP]
                    - mvp@spam.guard. caspershouse.co m

                    "Tomas Vera" <taveraNOSPAM@s bcglobalREMOVE. net> wrote in message
                    news:3hntk1t6ck ivd5jnejuj2udil g16am8i52@4ax.c om...[color=blue]
                    > Nicholas,
                    >
                    > Eventually, I need to be able to detect and use existing instances of
                    > MS Excel and Word for some applications that I'm developing. But I've
                    > only been playing with processes for about 2 days.
                    >
                    > So in the short term, I'm simply trying to get the process names to
                    > display them. I didn't expect that this should take as long as it
                    > does.
                    >
                    > I'll try it again this evening.
                    >
                    > Thanks for your help.
                    >
                    > -tomas
                    >
                    >
                    > On Thu, 13 Oct 2005 13:46:53 -0400, "Nicholas Paldino [.NET/C# MVP]"
                    > <mvp@spam.guard .caspershouse.c om> wrote:
                    >[color=green]
                    >>Tomas,
                    >>
                    >> That is a good number of processes. What information are you trying
                    >> to
                    >>retreive from the processes? It might be better to use WMI instead.[/color]
                    >[/color]


                    Comment

                    • Tomas Vera

                      #11
                      Re: GetProcesses hangs on XP

                      Nicholas,
                      Thanks. I cam across that yesteday after my posts.
                      So this issue is "dead" for now.

                      FYI, the example program that I posted did eventually run to
                      completion. Still it took 4 minutes to enumerate 42 processes.

                      The same program runs in less than half a second on my machine at work
                      with 33+ processes.

                      So there's something amiss with my steup at home.

                      Is it possible that some anti-virus software (Norton) can interfere
                      with this app?

                      Regadless, thanks for your help!

                      -tomas


                      On Fri, 14 Oct 2005 12:28:23 -0400, "Nicholas Paldino [.NET/C# MVP]"
                      <mvp@spam.guard .caspershouse.c om> wrote:
                      [color=blue]
                      >Tomas,
                      >
                      > If you are trying to get existing instances of Excel and Word, you
                      >shouldn't have to enumerate through the processes. You should be able to
                      >use the static GetActiveObject method on the Marshal class to automate
                      >running instances of Excel and Word.[/color]

                      Comment

                      Working...