popup form

T

TheOne

Hi I would like to have some kind of popup form that will display "search in
progress" or something else. On the main form once a user clicks on search I
would like to open another popup form and display message. Once I get
results back I would like to close that form and go back to main search
form. I assume that this has to be done with threading, but I was wondering
if anyone has some good code samples or ides how to do it?

Thanks,

Sinisa
 
G

Guest

Do you want the user to be able to do other things while the search is in
progress?

If you don't what you could do is build a simple form for displaying the
search in progress message and show it as a dialog from the main form. The
popup form could launch the search and store the results in a property once
they are complete. Setting the DialogResult will close the form. The main
form receives the DialogResult as the return value of the ShowDialog call and
can then access the results via the property if the DialogResult was OK.

If you want the user to continue to interact with the main form while the
search is in progress then create a simple form in the same way but show it
using Show instead of show dialog. You can then launch a thread to perform
the search. You will need to use the Control.Invoke method to make a
callback to pass the search results from the worker thread to the main UI
thread so that it can display the results. This article might be of use:
http://msdn.microsoft.com/library/d...evelopingMultithreadedWindowsFormsControl.asp

Good luck,

David Grant
 
J

Jeffrey Tan[MSFT]

Hi Sinisa,

Thanks for your posting!!

I think David has provided you a right direction, and my opinion is almost
the same with him.
For multithreading, the key point is the thread safty(interthread
communication), which David has pointed out: we should use Control.Invoke
to marshal the UI thread calling. There is also a good safe multithreading
article writen by Chris Sells:
"Safe, Simple Multithreading in Windows Forms, Part 1"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnforms/htm
l/winforms06112002.asp

In this article, Chris Sells made a simple Winform application which
calculate PI with the background thread processing. For your information.
======================================================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
G

Guest

Thats a really good article. Taken with the other two parts, its the best
one I've read on best practices for windows forms multithreading.

cheers for that,

David
 
J

Jeffrey Tan[MSFT]

Hi David,

Yes, I agree with you, it is really a good article!! Cheers!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jeffrey Tan[MSFT]

Hi Sinisa,

Ok, if you still have anything unclear, please feel free to feedback, we
will help you. Thanks!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top