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 / July 2006

Tip: Looking for answers? Try searching our database.

Multithread and UI again ! :)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
maxima - 25 Jul 2006 20:12 GMT
Hi,

I have done some coding with UI being accessed from different threads before.

But now I stuck. Need your help guys! :)

My application run not the form but some ApplicationContext class (in
function Main - Application.Run(new MyAppContext());)

That class creates 2 children. Model1 and Model2. Model1 being created in
MyAppContext constructor. In a turn frmMain being created in model1's
constructor as well..

So frmMain has no problem at all..

Model2 could be created in 2 different methods of MyAppClass. They being
called from Model1. In such a case (in Model2's constructor) frmSecond being
created and shown.

When it goes to method1 - frmSecond works fine. When it is from method2 -
frmSecond popping up to the screen but white and doesnt show anything.

All the methods which access UI in frmSecond - all are through Invoke thing.
So everything still works (I can see it in debuger). But doesnt show anything
on screen :(

Please help! :)
Dmytro Lapshyn [MVP] - 26 Jul 2006 08:06 GMT
Hi,

Can it be that you construct the second form on a worker thread?

The Invoke method can also be tricky - make sure that the control on which
you call Invoke was created on the main UI thread.

Signature

Regards,
Dmytro Lapshyn [MVP]
http://blogs.vbcity.com/DmytroL

> Hi,
>
[quoted text clipped - 27 lines]
>
> Please help! :)
maxima - 26 Jul 2006 09:55 GMT
Thanx Dmytro,

This is basically the question - how to ensure that 2nd form being created
in worker thread?

If we are talking abt a control - it is easy - whatever thread it is - you
test InvokeRequired etc.

I am trying to find similar way (abstracted solution which works in every
case) to create form.

Shall I create 2nd form in main form and pass it back to the wrapper classes?

Vlad

> Hi,
>
> Can it be that you construct the second form on a worker thread?
>
> The Invoke method can also be tricky - make sure that the control on which
> you call Invoke was created on the main UI thread.
Dmytro Lapshyn [MVP] - 26 Jul 2006 14:45 GMT
Yes, creating forms explicitly on the main thread is definitely a good idea.
However, you can pass a reference around safely only if you always pay
attention to the InvokeRequired property.

Signature

Regards,
Dmytro Lapshyn [MVP]
http://blogs.vbcity.com/DmytroL

> Thanx Dmytro,
>
[quoted text clipped - 19 lines]
>> which
>> you call Invoke was created on the main UI 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.