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 / October 2007

Tip: Looking for answers? Try searching our database.

Multi-threading forms?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Patrick - 29 Oct 2007 14:01 GMT
I have a "Main" ASP.NET 2  Form that could spawn off other forms using
 //e.g.
 NewSubForm myNewForm = new NewSubForm();
 myNewForm.Show();
 myNewForm.Activate();

The other forms perform something intensive "e.g. Invoke Oracle Stored
Procedure that take more than 10 seconds to bring back data".  However,
during this time, the main form are not accessible (all white), nor are other
sub-forms that had previously been spawned.

I thought unlike the VB6 days, forms are meant to be multi-threaded to
prevent this from happening?  How could I change the form
loading/instantiating to make them more multi-threaded?
Andrew Faust - 30 Oct 2007 02:28 GMT
I don't think you meant to say ASP.NET there did you? This is a Winforms
app not a web app right?

To answer your question, the GUI runs in a single thread. However, you can
easily create new threads and run your Oracle methods from that thread. For
example you could do this:

class MyForm : Form
{
   <Constructors And Initializer Code>

   void DoOracleProcedure()
   {
       <Do long DB Code here>
   }

   void Button1_Click(object sender, EventArgs args)
   {
       Thread th = new Thread(new ThreadStart(DoOracleProcedure));
       th.Start();
   }
}

With this, when you click the button a new thread will be created with an
entry point of DoOracleProcedure. When Start is called it will call the
method and the thread will run until the DoOracleProcedure returns. Any
method calls the DoOracleProcedure makes will run in the new thread. This
will keep your GUI responsive.

One thing to note, however. Should you need to update your GUI from a
separate thread there are some loops you need to jump through. Nothing
terribly difficult. Just mildly annoying.

Signature

Andrew Faust
andrew[at]andrewfaust.com
http://www.andrewfaust.com

>I have a "Main" ASP.NET 2  Form that could spawn off other forms using
>  //e.g.
[quoted text clipped - 11 lines]
> prevent this from happening?  How could I change the form
> loading/instantiating to make them more multi-threaded?

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.