Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

how to show a modeless form from a thread

Posted on 2004-03-21
3
Medium Priority
?
462 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 1000 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

636 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