Threading ...

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

    Threading ...

    If I use the System.Threadin g.ThreadPool.Qu eueUserWorkItem to spawn a new
    threaded process, will this process be executed regardless of whether or not
    the current process ends prior to completion of the child thread? Or do I
    need to create a new thread object and join it to my current thread in order
    to guarantee execution of code in a child process?

    -Ron


  • Dave

    #2
    Re: Threading ...

    If you successfully start a process by using
    System.Diagnost ics.Process.Sta rt() method then it will execute regardless of
    what the code that started it does. It is a separate process, not a child
    process of the process that created it.

    "ron" <rrudy@crosscur rent.com> wrote in message
    news:Oh34YoDiDH A.460@TK2MSFTNG P12.phx.gbl...[color=blue]
    > If I use the System.Threadin g.ThreadPool.Qu eueUserWorkItem to spawn a new
    > threaded process, will this process be executed regardless of whether or[/color]
    not[color=blue]
    > the current process ends prior to completion of the child thread? Or do I
    > need to create a new thread object and join it to my current thread in[/color]
    order[color=blue]
    > to guarantee execution of code in a child process?
    >
    > -Ron
    >
    >[/color]


    Comment

    • Ron

      #3
      Re: Threading ...

      Threads started under the System.Threadin g.Thread class
      cannot be included in a new process under the
      System.Diagnost ics.Process. Instead you need to use the
      System.Diagnost ics.ProcessThre ad class. This doesn't work
      for me under the current architecture. I'll likely need
      to join to the current thread in order to guarantee
      execution.

      -Ron[color=blue]
      >-----Original Message-----
      >If you successfully start a process by using
      >System.Diagnos tics.Process.St art() method then it will[/color]
      execute regardless of[color=blue]
      >what the code that started it does. It is a separate[/color]
      process, not a child[color=blue]
      >process of the process that created it.
      >
      >"ron" <rrudy@crosscur rent.com> wrote in message
      >news:Oh34YoDiD HA.460@TK2MSFTN GP12.phx.gbl...[color=green]
      >> If I use the[/color][/color]
      System.Threadin g.ThreadPool.Qu eueUserWorkItem to spawn a
      new[color=blue][color=green]
      >> threaded process, will this process be executed[/color][/color]
      regardless of whether or[color=blue]
      >not[color=green]
      >> the current process ends prior to completion of the[/color][/color]
      child thread? Or do I[color=blue][color=green]
      >> need to create a new thread object and join it to my[/color][/color]
      current thread in[color=blue]
      >order[color=green]
      >> to guarantee execution of code in a child process?
      >>
      >> -Ron
      >>
      >>[/color]
      >
      >
      >.
      >[/color]

      Comment

      • Dave

        #4
        Re: Threading ...

        If you want to start a unit of execution within the same managed process
        then use a System.Threadin g.Thread - this creates a managed thread within
        the same process. You can then use thread.Join to wait for that thread to
        complete. If it's not one of your threads (e.g. a threadpool) then you can
        use an event to signal the completion of the work, and then use
        WaitOne(event) in the main thread to wait for it to complete.

        If you want more isolation you can create another appdomain and run it in
        that appdomain. You can also run an executable in another appdomain using
        appDomain.Execu teAssembly(asse mblyPath), where appDomain is a reference to
        another appdomain.

        You can also use a named mutex for interprocess signalling. You can launch
        another process, win32 or managed code, and when that code completes it sets
        a mutex to the signalled state. The launching program can wait for that
        mutex to be signalled.

        It's not clear to me what you are trying to accomplish so it's not possible
        to determine what the best approach would be.

        "Ron" <rrudy@crosscur rent.com> wrote in message
        news:077101c389 12$7b8d72b0$a30 1280a@phx.gbl.. .[color=blue]
        > Threads started under the System.Threadin g.Thread class
        > cannot be included in a new process under the
        > System.Diagnost ics.Process. Instead you need to use the
        > System.Diagnost ics.ProcessThre ad class. This doesn't work
        > for me under the current architecture. I'll likely need
        > to join to the current thread in order to guarantee
        > execution.
        >
        > -Ron[color=green]
        > >-----Original Message-----
        > >If you successfully start a process by using
        > >System.Diagnos tics.Process.St art() method then it will[/color]
        > execute regardless of[color=green]
        > >what the code that started it does. It is a separate[/color]
        > process, not a child[color=green]
        > >process of the process that created it.
        > >
        > >"ron" <rrudy@crosscur rent.com> wrote in message
        > >news:Oh34YoDiD HA.460@TK2MSFTN GP12.phx.gbl...[color=darkred]
        > >> If I use the[/color][/color]
        > System.Threadin g.ThreadPool.Qu eueUserWorkItem to spawn a
        > new[color=green][color=darkred]
        > >> threaded process, will this process be executed[/color][/color]
        > regardless of whether or[color=green]
        > >not[color=darkred]
        > >> the current process ends prior to completion of the[/color][/color]
        > child thread? Or do I[color=green][color=darkred]
        > >> need to create a new thread object and join it to my[/color][/color]
        > current thread in[color=green]
        > >order[color=darkred]
        > >> to guarantee execution of code in a child process?
        > >>
        > >> -Ron
        > >>
        > >>[/color]
        > >
        > >
        > >.
        > >[/color][/color]


        Comment

        Working...