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 / April 2005

Tip: Looking for answers? Try searching our database.

Several forms each running on its own thread ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve Terepin - 23 Mar 2005 12:06 GMT
My application needs to have three Forms, each of which runs on its own thread ie with its own independent message loop etc. I've implemented this by creating three Thread instances, where the ThreadStart delegate points to a method that does something like this :

void MyThreadStart ( )
{
 System.Windows.Forms.Application.Run(
   new MyForm() // Different MyForm class for each thread
 ) ;
}

This works fine most of the time, but just occasionally (perhaps one time in ten) an exception gets thrown in the InitializeComponent method called by my Form's constructor. The error message tells me that a ThreadStateException has occurred. So maybe 'Application.Run' isn't the right way to do this. Any ideas, anyone ?

Thanks,

Steve.
Herfried K. Wagner [MVP] - 23 Mar 2005 14:52 GMT
"Steve Terepin" <steve.terepin@oxford-biosignals.com> schrieb:
>My application needs to have three Forms, each of which runs
> on its own thread ie with its own independent message loop etc.

I am just curious why you need that.  Maybe there is a better solution...

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>

Steve Terepin - 23 Mar 2005 15:51 GMT
Good question !  I'm developing a UI that will be packaged as a COM
component that will be used from a native C++ Win32 app. The UI needs to
have its own thread, so as not to hold up progress of the 'main' app which
is capturing real time data. And in fact there are three different kinds of
UI display, activated at different times. For debugging and testing, I have
a .Net console application that creates instances of all three UI forms and
sends them the same string-oriented messages that will eventually be coming
in from the native C++ app.

Yes, it is a bit convoluted !  But is there a good reason for *not* having
more than one thread servicing a UI ?

S.

> "Steve Terepin" <steve.terepin@oxford-biosignals.com> schrieb:
>>My application needs to have three Forms, each of which runs
>> on its own thread ie with its own independent message loop etc.
>
> I am just curious why you need that.  Maybe there is a better solution...
Nicholas Nezis - 01 Apr 2005 17:07 GMT
Steve,

I'm also facing this same problem. I want three different displays (maybe
more down the road) and the data I'm receiving is from a real time source. I
read it into a Main form but then want to display various waterfall displays
on various forms. Is the best option making various threads for each form?
I'm also thinking of using Managed DirectX for a few of the forms, and the
seperate thread would be nice to create a render loop. I want the user to be
able to turn dispalys on and off as each of the displays update. I apprecaite
any help on how to set up my project's structure.

Nicholas Nezis

> Good question !  I'm developing a UI that will be packaged as a COM
> component that will be used from a native C++ Win32 app. The UI needs to
[quoted text clipped - 15 lines]
> >
> > I am just curious why you need that.  Maybe there is a better solution...

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.