473,791 Members | 2,725 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Threading: Showing form in main-thread through different thread

Hello,

I know forms aren't thread-safe, but I'm a bit stuck here....

I have an MDI-Application which after 'Login' loads the Data from an SQL Server into DataSets.
Those DataSets are Parented on a "DataForm" which is loaded like this:
If IsNothing(Data) Then

Data = New frmData

MDI.containerDa ta.Controls.Add (Data) (MDI = MDI-Container)

With Data

..Dock = DockStyle.Fill

..Show()

End With

End If
The frmData has
Me.SetTopLevel( False)

.... So it's not an MDI-Child ...

In the Load-Event a Thread (trdData) is created to retreive the Data from the server.
After all the data has been loaded (still trdData) an instance is created of a popup-form to alert the user the Data has been loaded.
Dim pop As popMessage = New popMessage

pop.Show("Messa ge")

As you can see the Show-Method of the Form popMessage has been overloaded (to pass the message to display)

What happens is the popMessage gets displayed for about 0,05 seconds and disappears then.
I think the "Invoke-Method" should be called, but I can 't figure-out how

You might be thinking why I'm not using a msgbox... well the popMessage is like the pop-up Outlook 2003 has (together with the background & fading)
Any suggestions would be more then welcome.

TIA,

Michael
Nov 20 '05 #1
3 1234
* "Michael Maes" <mi*****@merlot .com> scripsit:
In the Load-Event a Thread (trdData)*is created to retreive the Data from the server.

After all the data has been loaded (still trdData) an instance is created of a popup-form to alert the user the Data has been
loaded.

Dim pop As popMessage = New popMessage

pop.Show("Messa ge")

As you can see the Show-Method of the Form popMessage has been overloaded (to pass the message to display)

*

What happens is the popMessage gets displayed for about 0,05 seconds and disappears then.

I*think the "Invoke-Method" should be called, but I can 't figure-out how


You can, for example, add a public method to one of your forms, and then
use the form's 'Invoke' method to call the message form. You will find
some resources and samples on multithreaded UIs there:

<URL:http://msdn.microsoft. com/library/en-us/dnforms/html/winforms0611200 2.asp>
<URL:http://msdn.microsoft. com/library/en-us/dnforms/html/winforms0816200 2.asp>
<URL:http://msdn.microsoft. com/library/en-us/dnforms/html/winforms0123200 3.asp>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2
Danke Herfried.

Together with a Form.Refresh I managed my goal.

Regards,

Michael
Nov 20 '05 #3
Danke Herfried.

Together with a Form.Refresh I managed my goal.

Regards,

Michael
Nov 20 '05 #4

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

Similar topics

1
3750
by: Andi Plotsky | last post by:
I have a subform where I dynamically change the SourceObject dependent upon the User's response to questions on the Main form. My problem is that the scrollbars do not show up on either the Main Form or the Subforms (except for on the opening form, but it doesn't scroll past the top viewable items). If I look at any of the forms separately, the scrollbars do show up and function just fine. The longest subform is 15", and so I have set...
1
3042
by: Henry | last post by:
I was trying to work through the Lab 2 exercises in the Microsoft's Windows-Based Applications in Visual C#. While I am not showing any errors I am also not seeing the mainMenu object when I run the application. I am wondering if someone could point out why in the code below: using System; using System.Drawing; using System.Collections;
4
3010
by: Grant Schenck | last post by:
I have a C# form application. Once my main window is showing I want to pop-up a login type dialog. What event would I trap to affect this? I tried handling the form load but the main form window is not yet visible then. Thanks! Grant Schenck
10
1348
by: Matt | last post by:
Hello Everyone I am making an instant messenger program. I have used the MSDN sockets example to get started with this. I have transfered the code that is found within this project into a class and can access it fine The problem is, that the messenger sends a message to the server which relays the message to the correct user: great, but there is a thread running that is reading the incomming data and passes it to a process sub that checks...
3
2038
by: simchajoy2000 | last post by:
Hi, I am designing an interface which allows users to load certain files into the interface. While the file is loading, I want to display a VB.NET form with the list of messages generated during the process. I want the form to be displayed during the loading process and the messages to appear one after another as they are generated in the back-end. I'm pretty sure I need to use multi-threading for this but I am having a lot of...
6
1163
by: John Dann | last post by:
I have a main form and then a secondary form that allows entry of some settings. I want to show the secondary form modally (I guess using ..ShowDialog), but I'd like it shown against the background of the main form. At present using frm2.showdialog eg from a main form menu click causes the main form to disappear from the background, which is a little disorientating for the user. Is this the standard behaviour of ShowDialog or have I got...
1
1899
by: kenduron | last post by:
Hello together! How would you manage the following termin: I got table "A" and table "B" I have to show most of the fields in "A", an one columm in table "B". But table "B" can have several entries which belongs to A.
4
3697
by: TonyJ | last post by:
Hello! I have a small program that just copy a file and make some checks in main then I just want to inform the user about something by using a MessageBox. I tried to use this in the MessageBox that is located in the main function. This cause compile error because you are not allowed to use this in a static function.
5
4209
by: John Dann | last post by:
Something very simple that I can't spot how to do: I wand to display a msgbox showing some current configuration parameters when my VB2005 program starts up. However, I want the main form to paint before the msgbox appears so that the main form appears as the background to the msgbox. At present I just have the msgbox as the last item in the Form.Load procedure but not surprisingly it's appearing on its own and out of context before the...
2
2619
by: mdejac | last post by:
I was wondering why the background color is not showing up in Mozilla. When I view the page there is a light blue background, when it should be black. Thank you for any help. http://www.myspace.com/mdejac <style type="text/css"> body { font-family: helvetica, arial, sans-serif; font-size: 62.5%; background-color: black; } table, td {
0
9515
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,...
0
10426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10207
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9993
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
9029
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
5558
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4109
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
3713
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2913
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.