Threading Help Required

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

    Threading Help Required

    I have a Windows Form that, on initialization, creates/starts a thread that
    runs a long process. When the user clicks the "Next" button on the windows
    form I need to wait until the thread is completed and then continue this
    what needs to be done. (using a call back function to enable the Next
    button when the thread is finished will not work)

    Currently I'm using a "While" loop to check the status of the thread. The
    problem with the "While" loop is that it is using up too many system
    resources to check the status that the thread takes too long to complete.
    Is there a way to check the status of a thread and if it is not complete
    then put the form to sleep for a few milliseconds to allow the thread to
    run?

    I've see the Thread.Sleep() method but I can't seem to find a Form.sleep()
    method.

    And if I start the Windows Form from within a Thread and put it to sleep
    will the sub thread (the one I've created on initialization of the Form) go
    to sleep as well?



  • ..::M:O:R:B:I:L:L:O::..

    #2
    Re: Threading Help Required

    [cut]

    i'm not sure of this , but you can consider my answer as possibile way.

    You can add to thread a event ( for ex. on_end or similar) so on event you
    get next in the application

    =o)


    ByE


    --
    ...::M:O:R:B:I: L:L:O::..


    Comment

    • David Browne

      #3
      Re: Threading Help Required


      "Fraser Baldwin" <Fraser_Baldwin @mail.com> wrote in message
      news:OuFVL2hUEH A.3504@TK2MSFTN GP11.phx.gbl...[color=blue]
      > I have a Windows Form that, on initialization, creates/starts a thread[/color]
      that[color=blue]
      > runs a long process. When the user clicks the "Next" button on the[/color]
      windows[color=blue]
      > form I need to wait until the thread is completed and then continue this
      > what needs to be done. (using a call back function to enable the Next
      > button when the thread is finished will not work)
      >
      > Currently I'm using a "While" loop to check the status of the thread. The
      > problem with the "While" loop is that it is using up too many system
      > resources to check the status that the thread takes too long to complete.
      > Is there a way to check the status of a thread and if it is not complete
      > then put the form to sleep for a few milliseconds to allow the thread to
      > run?
      >
      > I've see the Thread.Sleep() method but I can't seem to find a Form.sleep()
      > method.
      >[/color]

      Thread.Join

      Will sleep your current thread until a target thread completes.

      David


      Comment

      Working...