473,324 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

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?

Nov 20 '05 #1
2 901
[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::..
Nov 20 '05 #2

"Fraser Baldwin" <Fr************@mail.com> wrote in message
news:Ou**************@TK2MSFTNGP11.phx.gbl...
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
Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Z D | last post by:
Hello, I'm having a strange problem that is probably due to my lack of understanding of how threading & COM Interop works in a WinForms.NET application. Here's the situation: I have a 3rd...
3
by: chxant | last post by:
Hi, I tried a simple example of multi-threading, but it's not working. test() is never excecuted. What's wrong?? This is the code: using System; using System.Collections; using...
0
by: Colmeister | last post by:
I recently read Jason Clark's excellent article on Unhandled Exceptions (http://msdn.microsoft.com/msdnmag/issues/04/06/NET/default.aspx) and have attempted to incorporate the features he talks...
9
by: AdrianJMartin | last post by:
Hi all, I have a need for a STA thread from asp.net. I can create the thread and it runs fine. But when it is finished, the thread still 'hangs' arround. Visible only to the debugger..... I get...
6
by: hzgt9b | last post by:
Using VS 2003, .NET: I developed a windows application that performs several actions based on an input file. The application displays a progress bar as each action executes. Based on new...
14
by: Simon Verona | last post by:
I think I'm doing this wrong : I have a class with a public shared method such as follows: public shared sub myFunction dim frm as new myFrm dim t as new Threading.Thread(Addressof ...
1
by: Aaron | last post by:
Hi, 1. Can a seperate thread create a form? I created some test code. I have a sub Test that attempts to create and show a form, objFrmTest which is of type frmTest. Button1 and Button2...
7
by: Mike P | last post by:
I am trying to write my first program using threading..basically I am moving messages from an Outlook inbox and want to show the user where the process is up to without having to wait until it has...
126
by: Dann Corbit | last post by:
Rather than create a new way of doing things: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2497.html why not just pick up ACE into the existing standard:...
9
by: tshad | last post by:
I have a Windows App that is doing some work and then writing a "Now Processing..." line to the status line of the window as well as the Textbox on the form. But the problem is that the work is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.