On Fri, 30 Mar 2007 02:02:02 -0700, Chris
<Ch***@discussions.microsoft.comwrote:
This is my code in C#. but it does NOT work in the way I want :(
[...]
Perhaps if you describe the results you are getting with that code, and
how that differs from what you want, that would lead to one or more useful
replies.
For what it's worth, you should only need one additional thread (to do the
processing), and you do not need to do anything except return from your
ThreadStart delegate method to stop the thread (ie don't call Abort()).
It seems to me that you don't really even need the "please wait" form.
You presumably already have a form for your UI...it seems like you could
just display the text "please wait" (or similar) in the area where the
results of the processing will be displayed.
Whether you do that or display a new form, the basic idea is this:
Main thread:
* Create the thread to do your processing
* Display whatever UI to indicate the user should wait
Processing thread:
* Do the processing
* Use Invoke or BeginInvoke to run a method on the main thread that
clears the message to wait (either closes the form you've displayed, or
simply replaces the "please wait" message with the results of the
processing)
The Invoke/BeginInvoke is required because you will be interacting with
the form window, and any code that uses the form window has to be run on
the same thread that created the form.
Pete