Solved

how to show a modeless form from a thread

Posted on 2004-03-21
3
453 Views
Last Modified: 2012-06-27
hi
did anybody try to show a form from within a running thread? The form's object is declared as a member of the class that owns the thread and is initialized in the class's constructor. now in the thread's delegate, i call the show method (frm.Show()). Conceptually, since its a modeless show, the form should appear and tne tnread should go on with its work. however, just the border and the title of the form appear but nothing is drawn in the form.

why is that? is there any workaround solution?
0
Comment
Question by:mhdhallak
3 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 250 total points
ID: 10644929
Is is easy to understand why this happens - because thread doesn't have message loop.
I am not fun of user-interface threads. My approach is that UI elements should be always created in the main thread. Worker thread should do it's background work calling main thread forms ising Invoke or BeginInvoke. Since I don't like UI threads, I have never try to make them in .NET. After reading your question I tried to find something in .NET which allows to create UI thread, but I think this is not allowed.
So, make al UI work in the main thread. To create medeless form call some main (already existing) form method using Invoke or BeginInvoke. Create modeless form from this method.
0
 
LVL 8

Expert Comment

by:RomanPetrenko
ID: 10656192
Hi,
Take a look on this UI Threading Helper Classes, may be you can get something for your implementation
http://weblogs.asp.net/rosherove/articles/7171.aspx
0
 

Expert Comment

by:Matecocido
ID: 11023202
Use:

Application.Run(aForm) ;

inside thread and all work!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now