473,387 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

loading form from another thread

Hello

i have main mdi parent window from which i want to load a form, but
during creating form object and later calling its Show method i want
to display progress and have the main window responsive. But the problem is
that i cannot load form from another thread, when i try to set its
MdiParent property to main window, i get message that parent and child
cant be on separate threads. I could invoke Show without setting MdiParent,
but when i do that the window dont show up cause the thread terminates
after calling Show, and if i try to suspend it, i get only a part of my
form,
which is not responding. I know that this child form must have a message
loop. For now i create and set whole needed properties of window in separete
thread, and just calling Show in main thread, and it works.
But the best for me would be something like that: i create and invoke Show
on separete
thread, and later eventually i link somehow my child window with parent and
its thread.
thanks for any advices
best regards
roman
Feb 17 '06 #1
5 3182
Roman wrote:
i have main mdi parent window from which i want to load a form, but
during creating form object and later calling its Show method i want
to display progress and have the main window responsive. But the problem is
that i cannot load form from another thread, when i try to set its
MdiParent property to main window, i get message that parent and child
cant be on separate threads. I could invoke Show without setting MdiParent,
but when i do that the window dont show up cause the thread terminates
after calling Show, and if i try to suspend it, i get only a part of my
form, which is not responding.


<snip>

I don't believe you can do the UI part of what you want on a different
thread. However, what exactly is taking a long time when you're
creating the form? Is it doing stuff like fetching from a database? If
so, you could put *that* part into another thread, then create the form
itself on the main UI thread when the rest of the work has been done.

Jon

Feb 17 '06 #2
I don't believe you can do the UI part of what you want on a different
thread. However, what exactly is taking a long time when you're
creating the form? Is it doing stuff like fetching from a database? If
so, you could put *that* part into another thread, then create the form
itself on the main UI thread when the rest of the work has been done.


the problem is that i want to load not the forms i know, but the foreign
forms that i cant make any assumptions about. i think the most workload
there will be placed in load event of the form. i thought about calling load
handlers myself from loading separate thread but, they might also need
some controls ready and loaded, which means i probably should call it only
after form
is displayed by show. i was just wonder if it is possible to fully create
form
in other thread and then link it somehow to main ui thread
regards
roman
Feb 18 '06 #3
Roman <dz************@poczta.onet.pl> wrote:
I don't believe you can do the UI part of what you want on a different
thread. However, what exactly is taking a long time when you're
creating the form? Is it doing stuff like fetching from a database? If
so, you could put *that* part into another thread, then create the form
itself on the main UI thread when the rest of the work has been done.


the problem is that i want to load not the forms i know, but the foreign
forms that i cant make any assumptions about. i think the most workload
there will be placed in load event of the form. i thought about calling load
handlers myself from loading separate thread but, they might also need
some controls ready and loaded, which means i probably should call it only
after form is displayed by show. i was just wonder if it is possible to fully
create form in other thread and then link it somehow to main ui thread


I don't believe it is - unless there's some devious call in the Win32
API to "reparent" a UI in a different thread.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Feb 18 '06 #4
> I don't believe it is - unless there's some devious call in the Win32
API to "reparent" a UI in a different thread.


ok, thanks for you answer : )
lukasz cygan (roman)
Feb 18 '06 #5
As an implementation idea - you could use events - i.e. when the call finds
it needs to create a form it simply fires the event (indicating "what" on
the event args); to existing UI can catch this, Invoke to itself (to switch
threads) and then create the form. This keeps UI in the UI and data in the
data-tier.

Perhaps ;-0

Marc
Feb 18 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Rob | last post by:
I was working on a project and everything was going fine, then all of a sudden the form set as my startup object stopped loading. I tried setting some others as the startup object, and some of my...
3
by: Holmes | last post by:
Hello Ran into a bit of a problem here and have now exhausted my resources to getting this working What I am trying to do is load and show a simple vb form with a listbox in it Dim...
6
by: A.Weinman | last post by:
Hello all, I have an application that has multiple forms, only 3 of which matter for this issue. There is a main form that starts invisible and does nothing more than start other forms and link...
1
by: Franck | last post by:
I have a form with a loading bar as marquee so i don't need to play with the progress thing. It's just a form to show activity in other way. So what i need to do is start it at the beginning of...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.