473,693 Members | 2,547 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3217
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.co m>
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
1974
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 forms will load and others won't. Those that won't load at startup don't load with the Show or ShowDialog command either. Can anyone give me a hint as to what went wrong?
3
2608
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 frm_nc_code As New frm_nc_sen frm_nc_code.Show( Well what I want to have happen is it loads the form then shows all of the controls on the form (especially the listview control which should be blank at this time)
6
2391
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 them all together. I also have a Login form and a View form, both started by the main form. My goal is to have the Login form pop up as soon as the application is started, and at the same time have the View form start loading data, but stay...
1
5570
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 the process which take 10-30 sec depends and have to stop it at the end. I have to use thread so i can see activity. I just have a little problem. when i call my thread i see the form appearing and disappearing real fast (like a quarter second)....
0
8552
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8816
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8812
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7647
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5825
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4332
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2992
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2248
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.