Threading Help Required

  • Thread starter Thread starter Fraser Baldwin
  • Start date Start date
F

Fraser Baldwin

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?
 
Fraser Baldwin said:
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.

Thread.Join

Will sleep your current thread until a target thread completes.

David
 
[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
 
Back
Top