Solved

how to show a modeless form from a thread

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

717 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