Solved

how to show a modeless form from a thread

Posted on 2004-03-21
3
452 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 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

20 Experts available now in Live!

Get 1:1 Help Now