Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / March 2006

Tip: Looking for answers? Try searching our database.

prevent windows form from "hang"

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Julia - 09 Mar 2006 09:05 GMT
Hi,
Iam developing an application using windows forms as the gui. The
application is doing some heavy database work. While this work is done (I use
separate threads for this) I would like to print some information in the gui
but I dont know how to do, because it seems like the gui is locked? What can
I do to make this work?

Thanks
Julia
Stoitcho Goutsev (100) - 09 Mar 2006 14:32 GMT
Julia,

You can't modify the GUI from a worker thread. That has been asked many
times. You need to marshal the execution to the GUI thread and make the
modifications there; to do that you need to use Control.InvoleRequired and
Contro.Invoke memebers.

For more info:
http://msdn2.microsoft.com/en-us/library/ms171728.aspx

Signature

HTH
Stoitcho Goutsev (100)

> Hi,
> Iam developing an application using windows forms as the gui. The
[quoted text clipped - 8 lines]
> Thanks
> Julia
Bob Powell [MVP] - 09 Mar 2006 18:43 GMT
In addition to Stoitcho's suggestion you can use the same method to invoke a
method in your gui thread that just calls Application.DoEvents().

You could even run this call from a System.Timers.Timer that is running
while your other worker-thread is getting the database info. Invoke would
still be necessary though in either case.

Signature

Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

> Hi,
> Iam developing an application using windows forms as the gui. The
[quoted text clipped - 8 lines]
> Thanks
> Julia

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.