473,466 Members | 1,417 Online
Bytes | Software Development & Data Engineering Community
Create 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.containerData.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("Message")

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 1223
* "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("Message")

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/winforms06112002.asp>
<URL:http://msdn.microsoft.com/library/en-us/dnforms/html/winforms08162002.asp>
<URL:http://msdn.microsoft.com/library/en-us/dnforms/html/winforms01232003.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
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...
1
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...
4
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...
10
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...
3
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...
6
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...
1
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...
4
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...
5
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...
2
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. ...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.